matsumotory / mruby-annoy

AnnoyIndex class for mruby.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mruby-annoy Build Status

AnnoyIndex class for mruby.

Annoy is a C++ library to search for points in space that are close to a given query point. This mrbgem provides mruby bindings for the library.

Ruby code example

f = 40
t = AnnoyIndex.new(f)  # Length of item vector that will be indexed
1000.times do |i|
  v = f.times.map{rand}
  t.add_item(i, v)
end

t.build(10) # 10 trees
t.save('test.ann')

# ...

u = AnnoyIndex.new(f)
u.load('test.ann') # super fast, will just mmap the file
puts u.get_nns_by_item(0, 1000) # will find the 1000 nearest neighbors

API are compatible with Annoy Full Python API

install by mrbgems

  • add conf.gem line to build_config.rb
MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem :github => 'monochromegane/mruby-annoy'
end

License

MIT

Author

monochromegane

About

AnnoyIndex class for mruby.

License:Other


Languages

Language:C++ 88.0%Language:Ruby 9.7%Language:C 2.4%