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

Add detect-language CLI command #801

Merged
merged 3 commits into from
Sep 17, 2024
Merged

Add detect-language CLI command #801

merged 3 commits into from
Sep 17, 2024

Conversation

osma
Copy link
Member

@osma osma commented Sep 17, 2024

This PR adds a detect-language CLI command, as specified in #799.

Here is how it works:

$ echo "this is example text" | annif detect-language fi,sv,en
en	1.0000
sv	0.3333
fi	0.0000
?	0.0000

This is slightly different than what was proposed in #799. The candidate languages are given as an argument (comma-delimited) instead of a --languages option, and the unknown language case is shown as ? not -.

It's also possible to run this on multiple files, just like annif suggest:

$ annif detect-language fi,sv,en README.md LICENSE.txt 
Detected languages for README.md
en	0.7700
sv	0.2100
?	0.2000
fi	0.1400
Detected languages for LICENSE.txt
en	0.8857
sv	0.3714
fi	0.0857
?	0.0571

Special cases / errors:

$ echo "this is example text" | annif detect-language xx yy
Usage: annif detect-language [OPTIONS] [LANGUAGES]...
Try 'annif detect-language --help' for help.

Error: Unsupported language: xx
$ annif detect-language
Usage: annif detect-language [OPTIONS] LANGUAGES [PATHS]...
Try 'annif detect-language --help' for help.

Error: Missing argument 'LANGUAGES'.

Closes #799

@osma osma added this to the 1.2 milestone Sep 17, 2024
@osma osma self-assigned this Sep 17, 2024
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.65%. Comparing base (c81ed1c) to head (0dda55b).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #801   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files          93       93           
  Lines        6889     6939   +50     
=======================================
+ Hits         6865     6915   +50     
  Misses         24       24           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

sonarcloud bot commented Sep 17, 2024

@osma osma merged commit 2611586 into main Sep 17, 2024
16 of 17 checks passed
@osma osma deleted the issue799-language-detection-cli branch September 17, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Language detection method in CLI
2 participants