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

Simplify language identification using dictionary mapping #898

Closed
wants to merge 4 commits into from

Conversation

Arker123
Copy link
Collaborator

@Arker123 Arker123 commented Nov 9, 2023

This PR suggests using a dictionary mapping approach for language identification.

Copy link
Collaborator

@williballenthin williballenthin left a comment

Choose a reason for hiding this comment

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

can't we just do Language(args.language)?

(need a try/except to handle missing cases)

@williballenthin
Copy link
Collaborator

while we're at it, we may want to derive the argparse choices from the Language enum.

floss/main.py Outdated
Comment on lines 201 to 202
choices=[lang.value for lang in Language],
default="none",
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this include the unknown language in the usage output and allow to use "none"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this change includes the unknown. I've updated it to allow "none" and not "Unknown" in latest commit 😄

else:

try:
lang_id = Language(args.language)
Copy link
Collaborator

Choose a reason for hiding this comment

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

how can users disable language detection now?

@mr-tz
Copy link
Collaborator

mr-tz commented Nov 12, 2023

now part of #901

@mr-tz mr-tz closed this Nov 12, 2023
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.

3 participants