-
Notifications
You must be signed in to change notification settings - Fork 0
config wikidata max results per search #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ authors = [ | |
| readme = "README.md" | ||
| requires-python = "<4.0,>=3.13" | ||
| dependencies = [ | ||
| "wikibaseintegrator (>=0.12.12,<0.13.0)", | ||
| "wikibaseintegrator @ git+https://github.com/LeMyst/WikibaseIntegrator.git@301067883ddce0bca31fdd54973c3d6c8cbbcb7d", | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is temporary to get around a login issue. |
||
| "pyairtable (>=3.1.1,<4.0.0)", | ||
| "more_itertools" | ||
| ] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,5 +33,9 @@ class airtable: | |
|
|
||
| wbi = WikibaseIntegrator() | ||
|
|
||
| WIKIDATA_MAX_RESULTS_PER_SEARCH: int = int( | ||
| os.getenv("WIKIDATA_MAX_RESULTS_PER_SEARCH", 50) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using 50 to match the library's default, but realistically, we probably want just 5, which is what I've set in the public repo var |
||
| ) | ||
|
|
||
|
|
||
| LANGUAGE_CODE = "en" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,10 @@ | |
|
|
||
|
|
||
| def get_matches( | ||
| items: list[ctfg.Listing], max_attempts=None, from_cache=False | ||
| items: list[ctfg.Listing], | ||
| max_attempts=None, | ||
| from_cache=False, | ||
| max_results: int = 50, | ||
| ) -> dict[ctfg.Listing, list[dict[str, Any]]]: | ||
| matchable_items = [x for x in items if x.name] | ||
| attempting_items = ( | ||
|
|
@@ -27,7 +30,9 @@ def get_matches( | |
| else: | ||
| wiki_matches = {} | ||
| for x in attempting_items: | ||
| raw_matches = search_entities(x.name, "en", dict_result=True) | ||
| raw_matches = search_entities( | ||
| x.name, config.LANGUAGE_CODE, dict_result=True, max_results=max_results | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also configured language here where it was previously missed |
||
| ) | ||
| wiki_matches[x] = raw_matches | ||
|
|
||
| if not max_attempts: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core fix making results configurable to reduce noise and airtable limits.