Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"d", "c", "bdaf", "ddcd",
"egbfa", "a", "fba", "bcccfe",
"ab", "bfgbfdc", "bcbbgf", "bfbb"
]
QUERY_STRS = ["abc", "def", "ghik"]
space_type = 'leven'
space_param = []
method_name = 'small_world_rand'
index_name = method_name + '.index'
index = nmslib.init(
space_type,
space_param,
method_name,
nmslib.DataType.OBJECT_AS_STRING,
nmslib.DistType.INT)
for id, data in enumerate(DATA_STRS):
nmslib.addDataPoint(index, id, data)
print('Let\'s print a few data entries')
print('We have added %d data points' % nmslib.getDataPointQty(index))
for i in range(0,min(MAX_PRINT_QTY,nmslib.getDataPointQty(index))):
print(nmslib.getDataPoint(index,i))
print('Let\'s invoke the index-build process')
index_param = ['NN=17', 'efConstruction=50', 'indexThreadQty=4']
query_time_param = ['efSearch=50']
def setUp(self):
space_type = 'leven'
space_param = []
method_name = 'small_world_rand'
index_name = method_name + '.index'
if os.path.isfile(index_name):
os.remove(index_name)
self.index = nmslib.init(
space_type,
space_param,
method_name,
nmslib.DataType.OBJECT_AS_STRING,
nmslib.DistType.INT)
for idx, data in enumerate(read_data_as_string('sample_queryset.txt')):
print(idx, nmslib.knnQuery(index, k, data))
nmslib.saveIndex(index, index_name)
print("The index %s is saved" % index_name)
nmslib.freeIndex(index)
if __name__ == '__main__':
print('DENSE_VECTOR', nmslib.DataType.DENSE_VECTOR)
print('SPARSE_VECTOR', nmslib.DataType.SPARSE_VECTOR)
print('OBJECT_AS_STRING', nmslib.DataType.OBJECT_AS_STRING)
print('DistType.INT', nmslib.DistType.INT)
print('DistType.FLOAT', nmslib.DistType.FLOAT)
test_vector_load()
test_vector_fresh()
test_vector_fresh(False)
test_vector_loaded()
gen_sparse_data()
test_sparse_vector_fresh()
test_string_fresh()
test_string_fresh(False)
test_string_loaded()