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

Closest Match for Punjabi (Pakistan) Not Resolving Match #59

Open
joe-sciame-wm opened this issue Nov 28, 2022 · 4 comments
Open

Closest Match for Punjabi (Pakistan) Not Resolving Match #59

joe-sciame-wm opened this issue Nov 28, 2022 · 4 comments

Comments

@joe-sciame-wm
Copy link

joe-sciame-wm commented Nov 28, 2022

I'm attempting to match a language code 'pa' with another language code 'pa-PK'.

def test_language_less_than():
    spoken_language_1 = 'pa'
    spoken_language_2 = 'pa-PK'
    match = closest_match(spoken_language_1, [spoken_language_2])
    print(match)
    self.assertEqual(0, match[1])`

def test_language_more_than(self):
    spoken_language_1 = 'pa-PK'
    spoken_language_2 = 'pa'
    match = closest_match(spoken_language_1, [spoken_language_2])
    print(match)
    self.assertEqual(0, match[1])`

This returns

('und', 1000)
('und', 1000)

I would expect this to return a match and not None. When I debug the library, I see the following which returns 54 from the tuple_distance_cached function.

desired_triple = ('pa', 'Arab', 'PK')
supported_triple = ('pa', 'Guru', 'IN')

@joe-sciame-wm
Copy link
Author

I believe the issue here is that the maximize() language function is resolving pa and pa-PK to different maximized languages. I'm not a linguistic expert so I don't know if this is correct or not.

'pa': 'pa-Guru-IN',
'pa-PK': 'pa-Arab-PK',

@BrightXiaoHan
Copy link

Similar issue here.

In [4]: langcodes.get("ko").language_name()
Out[4]: 'Korean'

In [5]: langcodes.get("kor_Hang").language_name()
Out[5]: 'Korean'

In [6]: langcodes.closest_match("ko", ["kor_Hang"])
Out[6]: ('und', 1000)

@georgkrause
Copy link
Contributor

@BrightXiaoHan @joe-sciame-wm Thank you for the input! There is likely something to improve here. If I had to guess, I think the reason for this commit was exactly the problem you are describing: georgkrause@59326f8

Some formal hint: I took over the package and I am working on updating it here: https://github.com/georgkrause/langcodes
Sadly I cannot move issues, so I created a new one and maybe we can proceed the discussion there.

@zhu
Copy link
Contributor

zhu commented Apr 11, 2024

I think script tag is unnecessary when matching spoken languages.
Maybe add a ignore_script argument to closest_match function?

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

No branches or pull requests

4 participants