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

PetrovichGenderDetector raises StopIteration instead return ANDROGYNOUS gender #6

Open
kosdmit opened this issue Sep 12, 2024 · 2 comments

Comments

@kosdmit
Copy link

kosdmit commented Sep 12, 2024

Код ниже вызывает исключение StopIteration:

gender_detector = PetrovichGenderDetector()
gender = gender_detector.detect(middlename='Блаблабла')

Думаю в таком случае метод detect должен возвращать Gender.ANDROGYNOUS

@alexeyev
Copy link
Collaborator

Pytrovich merely clones the original Petrovich behavior, will check whether it returns the same response.

@kosdmit
Copy link
Author

kosdmit commented Sep 16, 2024

For example, we need to always use try-except with PetrovichGenderDetector:

        gender_detector = PetrovichGenderDetector()
        try:
            gender = gender_detector.detect(lastname=lastname, firstname=firstname, middlename=middlename)
        except StopIteration as e:
            logger.warning(f'Can not to predict gender to inflect {self.signatory}, default value will be used (MALE)')
            gender = Gender.MALE

It's not intuitive, especially the StopIteration exception.
Probably it would be better if we would returned ANDROGYNOUS or something like UNKNOWN. What do you think?

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

2 participants