-
Notifications
You must be signed in to change notification settings - Fork 72
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
Introduced QID search in translation. #545
Conversation
Thank you for the pull request!The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Data rooms once you're in. Also consider joining our bi-weekly Saturday dev syncs. It'd be great to have you! Maintainer checklist |
@@ -124,39 +124,6 @@ def get_datatype_list(language): | |||
return data_type_metadata | |||
|
|||
|
|||
def check_qid_is_language(qid: str): |
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.
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.
😄
src/scribe_data/utils.py
Outdated
instance_of_values = request_result["statements"]["P31"] | ||
for val in instance_of_values: | ||
if val["value"]["content"] == "Q34770": |
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.
🤔 Coming across this..
was actually wondering if we do have it documented somewhere what P31
or Q34770
refer to in Wikidata (and also all other important IDs that we reference in code too).
If not, should we? Was thinking that a quick markdown table could suffice really.
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.
Or actually - scratch that
It might be more helpful perhaps if that information is closer to where it's used in code.
So in-source comments instead?
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.
Does another metadata file make sense for this? That way we reference an object and get the QID from a human readable object key?
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.
Does another metadata file make sense for this?
hmm could be 🤔
Were you thinking of something like this?
# Instead of...
# instance_of_values = request_result["statements"]["P31"]
instance_of_property = wikidata["property"]["instance-of"]
instance_of_values = request_result["statements"][instance_of_property]
for val in instance_of_values:
# Instead of...
# if val["value"]["content"] == "Q34770":
if val["value"]["content"] == wikidata["entity"]["language"]:
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.
Along the lines of this, yes :)
src/scribe_data/utils.py
Outdated
response = requests.get(api_endpoint) | ||
data = response.json() | ||
try: | ||
return data["entities"][qid]["claims"]["P305"][0]["mainsnak"]["datavalue"][ |
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.
... was actually wondering if we do have it documented somewhere what P31 or Q34770 refer to in Wikidata (and also all other important IDs that we reference in code too) ...
ditto
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.
Thanks for the changes here, @axif0! This will make it much easier to figure out when we have enough translations on Wikidata to then make the switch of the translation functionality viable 😊
Quick note, @wkyoshida, that the above changes were made with @axif0 in the call and we discussed them while we prepared this for merging :) Just so you know that we did actively discuss the feedback and I didn't just do it myself 😇 |
Contributor checklist
pytest
command as directed in the testing section of the contributing guideDescription
Added QID search for total, translation and forms. Even a language is not present in language_metadata.json we can use QID to get total, translation and forms.
For total