Document utilities
This commit is contained in:
parent
2b378114aa
commit
00568ca6d3
21 changed files with 371 additions and 29 deletions
|
|
@ -4,6 +4,28 @@ from langcodes import standardize_tag, tag_distance
|
|||
|
||||
|
||||
def is_english(language_code: Optional[str]) -> bool:
|
||||
"""Decide whether the `language_code` is of an English language.
|
||||
|
||||
A thin wrapper over [langcodes](https://github.com/rspeer/langcodes) for convenient
|
||||
language tagging.
|
||||
|
||||
Examples:
|
||||
>>> is_english('en-US')
|
||||
True
|
||||
|
||||
>>> is_english(None)
|
||||
False
|
||||
|
||||
>>> is_english('und')
|
||||
False
|
||||
|
||||
Args:
|
||||
language_code: Language code, for example, returned by
|
||||
`[great_ai.utilities.predict_language][].
|
||||
|
||||
Returns:
|
||||
Boolean indicating whether it's English.
|
||||
"""
|
||||
if not language_code:
|
||||
language_code = "und"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue