-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added ignore_script
and tested it.
#17
base: main
Are you sure you want to change the base?
Conversation
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.
@mtr-d3v Thank you for the contribution! I had to close and reopen the PR because I failed to find another way to execute the Actions. I have left some comments, which is just one typo and two smaller issues regarding the style, which is open for discussion. Let me know if you are still interested in working on this, if not I'd be ready to take over.
if ignore_script: | ||
desired_triple = ( | ||
desired_complete.language, | ||
None, | ||
desired_complete.territory, | ||
) | ||
else: | ||
desired_triple = ( | ||
desired_complete.language, | ||
desired_complete.script, | ||
desired_complete.territory, | ||
) |
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.
I'd prefer the following:
if ignore_script: | |
desired_triple = ( | |
desired_complete.language, | |
None, | |
desired_complete.territory, | |
) | |
else: | |
desired_triple = ( | |
desired_complete.language, | |
desired_complete.script, | |
desired_complete.territory, | |
) | |
desired_triple = ( | |
desired_complete.language, | |
None if ignore_script else desired_complete.script, | |
desired_complete.territory, | |
) |
if ( | ||
supported.language is None | ||
and supported.script is None | ||
and supported.territory is None | ||
): | ||
supported_triple = ('und', 'Zzzz', 'ZZ') | ||
supported_triple = ('und', 'Zzzz', 'ZZ') |
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.
I think thats a mistake, can you removed the added whitespaces?
if ignore_script: | ||
supported_triple = ( | ||
supported_complete.language, | ||
None, | ||
supported_complete.territory, | ||
) | ||
else: | ||
supported_triple = ( | ||
supported_complete.language, | ||
supported_complete.script, | ||
supported_complete.territory, | ||
) |
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.
This can be simplified as shown above.
@@ -1791,14 +1807,20 @@ def tag_distance(desired: Union[str, Language], supported: Union[str, Language]) | |||
|
|||
>>> tag_distance('ja', 'ja-Latn-US-hepburn') | |||
54 | |||
|
|||
If `ignore_script` is used, the script difference is ignored and a smaller | |||
differenge with lower score will be found. |
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.
Typo:
differenge with lower score will be found. | |
difference with lower score will be found. |
match = closest_match( | ||
spoken_language_1, [spoken_language_2], ignore_script=True | ||
) | ||
print(match) |
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.
I think print in tests is hard to manage on executing time, do we need the debug output? If yes, I'd prefer using logging
92171c9
to
9856e6a
Compare
This PR fixes issue rspeer#59 by adding
ignore_script
and tests them.