Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mtrd3v
Copy link

@mtrd3v mtrd3v commented Jul 27, 2024

This PR fixes issue rspeer#59 by adding ignore_script and tests them.

@georgkrause georgkrause closed this Sep 6, 2024
@georgkrause georgkrause reopened this Sep 6, 2024
Copy link
Owner

@georgkrause georgkrause left a 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.

Comment on lines +708 to +719
if ignore_script:
desired_triple = (
desired_complete.language,
None,
desired_complete.territory,
)
else:
desired_triple = (
desired_complete.language,
desired_complete.script,
desired_complete.territory,
)
Copy link
Owner

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:

Suggested change
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')
Copy link
Owner

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?

Comment on lines +729 to +740
if ignore_script:
supported_triple = (
supported_complete.language,
None,
supported_complete.territory,
)
else:
supported_triple = (
supported_complete.language,
supported_complete.script,
supported_complete.territory,
)
Copy link
Owner

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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
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)
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants