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

simplemma.lang_detector import no longer working #111

Closed
osma opened this issue Aug 11, 2023 · 3 comments · Fixed by #129
Closed

simplemma.lang_detector import no longer working #111

osma opened this issue Aug 11, 2023 · 3 comments · Fixed by #129
Labels
bug Something isn't working documentation Improvements or additions to documentation
Milestone

Comments

@osma
Copy link
Contributor

osma commented Aug 11, 2023

I noticed that the language detection example in the README is no longer working in current main version.

Using simplemma==0.9.1 it works as advertised (although the returned ratios are a bit different from those in the README):

>>> from simplemma import in_target_language, lang_detector
>>> lang_detector('"Exoplaneta, též extrasolární planeta, je planeta obíhající kolem jiné hvězdy než kolem Slunce."', lang=("cs", "sk"))
[('cs', 0.8), ('unk', 0.19999999999999996), ('sk', 0.1)]

But with current main version the import of simplemma.lang_detector is not working:

>>> from simplemma import in_target_language, lang_detector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'lang_detector' from 'simplemma'

It works if I change lang_detector to langdetect:

>>> from simplemma import in_target_language, langdetect
>>> langdetect('"Exoplaneta, též extrasolární planeta, je planeta obíhající kolem jiné hvězdy než kolem Slunce."', lang=("cs", "sk"))
[('cs', 0.75), ('sk', 0.125), ('unk', 0.25)]

Should the documentation be fixed to correspond with the current naming in the code, or the function langdetect renamed back to lang_detector so the API remains stable?

@adbar adbar added documentation Improvements or additions to documentation bug Something isn't working labels Aug 11, 2023
@adbar
Copy link
Owner

adbar commented Aug 11, 2023

I guess we can use an alias an import it during init. This was a question we discussed with @juanjoDiaz but something must have got lost around the way.

@adbar adbar added this to the v1.0 milestone Aug 11, 2023
@adbar
Copy link
Owner

adbar commented Aug 11, 2023

This has already been mentioned in #64.

  • The 0.9.1 readme says: from simplemma.langdetect import in_target_language, lang_detector
  • The current readme says from simplemma import in_target_language, lang_detector

So we could go for an alias lang_detector = langdetect in the init file or we could simply rename the function.

In any case, the release notes have to mention that the import strategy is slighly different.

@adbar
Copy link
Owner

adbar commented Aug 11, 2023

See also 58b3ee7:
from simplemma.langdetectfrom simplemma.language_detector

@adbar adbar linked a pull request May 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants