Skip to content

Commit

Permalink
Include "algorithm" in all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Oct 4, 2023
1 parent 49e46b1 commit c3e362d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions examples/match_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@
# ID that we can recognize it by later:
BATCH = {"queries": {"q1": EXAMPLE_1, "q2": EXAMPLE_2}}

# Send the batch off to the API and raise an exception for a non-OK response code.
# Configure an API key for the service. This is required for the hosted API.
headers = {"Authorization": f"Apikey {API_KEY}"}
response = requests.post(URL, json=BATCH, headers=headers)

# This configures the scoring system. "fuzzy" is related only to the pre-retrieval
# of entities and can be turned off for a performance boost.
params = {"algorithm": "best", "fuzzy": "false"}

# Send the batch off to the API and raise an exception for a non-OK response code.
response = requests.post(URL, json=BATCH, headers=headers, params=params)
response.raise_for_status()

responses = response.json().get("responses")
Expand Down
6 changes: 5 additions & 1 deletion examples/match_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@
# ID that we can recognize it by later:
BATCH = {"queries": {"q1": EXAMPLE_1, "q2": EXAMPLE_2, "q3": EXAMPLE_3}}

# This configures the scoring system. "fuzzy" is related only to the pre-retrieval
# of entities and can be turned off for a performance boost.
PARAMS = {"algorithm": "best", "fuzzy": "false"}

# Send the batch off to the API and raise an exception for a non-OK response code.
response = requests.post(URL, json=BATCH)
response = requests.post(URL, json=BATCH, params=PARAMS)
if not response.ok:
pprint(response.json())
sys.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion examples/match_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
for fuzzy in (True, False):
start = time.time()
for i in range(100):
params = {"fuzzy": fuzzy}
params = {"fuzzy": fuzzy, "algorithm": "best"}
response = requests.post(URL, json=BATCH, params=params)
if not response.ok:
print("FAIL", response.status_code)
Expand Down

0 comments on commit c3e362d

Please sign in to comment.