-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable using get_language_detector with many languages + add unit test
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Unit tests for Simplemma utility functions""" | ||
|
||
from annif.simplemma_util import get_language_detector | ||
|
||
|
||
def test_get_language_detector(): | ||
detector = get_language_detector("en") | ||
text = "She said 'au revoir' and left" | ||
proportion = detector.proportion_in_target_languages(text) | ||
assert proportion == 0.75 | ||
|
||
|
||
def test_get_language_detector_many(): | ||
detector = get_language_detector(("en", "fr")) | ||
text = "She said 'au revoir' and left" | ||
proportion = detector.proportion_in_target_languages(text) | ||
assert proportion == 1.0 |