Skip to content

Commit b013949

Browse files
committed
example/vectorsearch: count -> num #31
1 parent 55f745f commit b013949

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

example/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ ID Name Latitude Longitude
5050
28 Berlin 52.52 13.40
5151
29 Bern 46.95 7.45
5252
> city_neighbors Berlin
53-
> city_neighbors Berlin
5453
ID Name Latitude Longitude Score
5554
147 Prague 50.08 14.44 7.04
5655
49 Copenhagen 55.68 12.57 10.66

example/vectorsearch-cities/__main__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,47 +46,47 @@ def do_ls(self, name: str = ""):
4646
list_cities(query.find())
4747

4848
def do_city_neighbors(self, args: str):
49-
"""find <count> (default: 5) next neighbors to city <name>\nusage: city_neighbors <name>, [,<count>]"""
49+
"""find <num> (default: 5) next neighbors to city <name>\nusage: city_neighbors <name> [,<num>]"""
5050
try:
5151
args = args.split(',')
5252
if len(args) > 2:
5353
raise ValueError()
5454
city = args[0]
5555
if len(city) == 0:
5656
raise ValueError()
57-
count = 5
57+
num = 5
5858
if len(args) == 2:
59-
count = int(args[1])
59+
num = int(args[1])
6060
qb = self._box.query()
6161
qb.equals_string(self._name_prop, city)
6262
query = qb.build()
6363
cities = query.find()
6464
if len(cities) == 1:
6565
location = cities[0].location
6666
qb = self._box.query()
67-
qb.nearest_neighbors_f32(self._location_prop, location, count+1) # +1 for the city
67+
qb.nearest_neighbors_f32(self._location_prop, location, num+1) # +1 for the city
6868
qb.not_equals_string(self._name_prop, city)
6969
neighbors = qb.build().find_with_scores()
7070
list_cities_with_scores(neighbors)
7171
else:
7272
print(f"no city found named '{city}'")
7373
except ValueError:
74-
print("usage: city_neighbors <name>[,<count>]")
74+
print("usage: city_neighbors <name>[,<num: default 5>]")
7575

7676
def do_neighbors(self, args):
77-
"""find <count> neighbors to geo-coord <lat> <long>.\nusage: neighbors <count>,<latitude>,<longitude>"""
77+
"""find <num> neighbors next to geo-coord <lat> <long>.\nusage: neighbors <num>,<latitude>,<longitude>"""
7878
try:
7979
args = args.split(',')
8080
if len(args) != 3:
8181
raise ValueError()
82-
count = int(args[0])
82+
num = int(args[0])
8383
geocoord = [ float(args[1]), float(args[2]) ]
8484
qb = self._box.query()
85-
qb.nearest_neighbors_f32(self._location_prop, geocoord, count)
85+
qb.nearest_neighbors_f32(self._location_prop, geocoord, num)
8686
neighbors = qb.build().find_with_scores()
8787
list_cities_with_scores(neighbors)
8888
except ValueError:
89-
print("usage: neighbors <count>,<latitude>,<longitude>")
89+
print("usage: neighbors <num>,<latitude>,<longitude>")
9090

9191
def do_add(self, args: str):
9292
"""add new location\nusage: add <name>,<lat>,<long>"""

0 commit comments

Comments
 (0)