Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Outline

Annoy + Flask

Annoy 是一个非常好用的近邻搜索库

from annoy import AnnoyIndex

f = 40       # dim of the feature
t = AnnoyIndex(f)
# 1000,代表一共有1000个实例
# FEATURE(i),代表第i个实例的特征
for i in xrange(1000):
    v = FEATURE(i)
    t.add_item(i, v)

t.build(10) # 10 trees
t.save('test.ann')
# ...use..
u = AnnoyIndex(f)
u.load('test.ann') # super fast, will just mmap the file
print(u.get_nns_by_vector(FEATURE(0), 10)) # will find the 1000 nearest neighbors

Flask 是一个python web 框架,在这里直接用了别人模板。

整个服务的核心就在view.py

:)

Morty Proxy This is a proxified and sanitized view of the page, visit original site.