Skip to content

Commit

Permalink
All fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrd3v committed Jul 27, 2024
1 parent dd54863 commit 92171c9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion langcodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,9 @@ def distance(self, supported: 'Language', ignore_script: bool = False) -> int:
This method returns a number from 0 to 134 measuring the 'distance'
between the languages (lower numbers are better). This is not a
symmetric relation.
symmetric relation. If `ignore_script` is `True`, the script will
not be used in the comparison, possibly resulting in a smaller
'distance'.
The language distance is not really about the linguistic similarity or
history of the languages; instead, it's based largely on sociopolitical
Expand Down Expand Up @@ -1805,6 +1807,12 @@ 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.
>>> tag_distance('ja', 'ja-Latn-hepburn', ignore_script=True)
0
>>> # You can read the Shavian script, right?
>>> tag_distance('en', 'en-Shaw')
Expand Down Expand Up @@ -1868,6 +1876,9 @@ def closest_match(
value is 25, and raising it can cause data to be processed in significantly
the wrong language. The documentation for `tag_distance` describes the
distance values in more detail.
`ignore_script` makes the matching ignore scripts, allowing matches to be
found when they wouldn't otherwise be due to different scripts.
When there is a tie for the best matching language, the first one in the
tie will be used.
Expand All @@ -1886,6 +1897,9 @@ def closest_match(
>>> closest_match('ja', ['ja-Latn-hepburn', 'en'])
('und', 1000)
>>> closest_match('ja', ['ja-Latn-hepburn', 'en'], ignore_script=True)
('ja-Latn-hepburn', 0)
"""
desired_language = str(desired_language)

Expand Down

0 comments on commit 92171c9

Please sign in to comment.