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

Rework grammar inflection parsing #176

Merged
merged 1 commit into from
Feb 25, 2024
Merged

Rework grammar inflection parsing #176

merged 1 commit into from
Feb 25, 2024

Conversation

radomirbosak
Copy link
Owner

@radomirbosak radomirbosak commented Sep 23, 2022

See changed docs:

Fixes: #156

TODO:

  • Documentation
  • Fix code style
  • Changelog
  • Consider renaming Grammar to Inflection
  • Export inflection enums to base package (from duden import Case, Person, Mood)
  • Remove grammar
    • Remove/deprecate functions
    • Remove documentation
    • Remove/deprecate CLI --grammar
    • Remove from tests
    • remove constants
  • Inflect
    • Add functions
    • Add CLI option
    • Add documentation
    • Add tests

TODO in later PR:

Usage

module

> inf = get("Hase").inflection
> inf
(Inflector: 'der Hase', ...)

> inf.data
{'Deklination': {'Singular': {'Nominativ': 'der Hase',
   'Akkusativ': 'den Hasen',
   'Dativ': 'dem Hasen',
   'Genitiv': 'des Hasen'},
  'Plural': {'Nominativ': 'die Hasen',
   'Akkusativ': 'die Hasen',
   'Dativ': 'den Hasen',
   'Genitiv': 'der Hasen'}}}

> inf.noun_decline(Number.SINGULAR, Case.DATIVE)
'dem Hasen'

> inf.noun_decline(Number.SINGULAR, "Kusative")
ValueError: Cannot inflect. Missing data for: 'Deklination'.'Singular'.'Kusative' . Did you mean 'Nominativ', 'Akkusativ', 'Dativ', 'Genitiv'?

CLI

$ duden Hase --inflect
Deklination:
  Plural:
    Akkusativ: die Hasen
    Dativ: den Hasen
    Genitiv: der Hasen
    Nominativ: die Hasen
  Singular:
    Akkusativ: den Hasen
    Dativ: dem Hasen
    Genitiv: des Hasen
    Nominativ: der Hase

@radomirbosak radomirbosak changed the title WIP: grammar WIP: Fix fetching grammar data Sep 26, 2022
@radomirbosak radomirbosak changed the title WIP: Fix fetching grammar data WIP: Reword grammar inflection parsing Sep 26, 2022
@radomirbosak radomirbosak changed the title WIP: Reword grammar inflection parsing WIP: Rework grammar inflection parsing Sep 26, 2022
@radomirbosak radomirbosak force-pushed the grammar branch 2 times, most recently from 4165c66 to dbe786d Compare October 3, 2022 00:01
@radomirbosak radomirbosak changed the title WIP: Rework grammar inflection parsing Rework grammar inflection parsing Feb 25, 2024
@radomirbosak
Copy link
Owner Author

Even if this is not finished, I need to merge this so that the project is not slowed down further. Unfinished parts will be fixed by subsequent MRs.

@radomirbosak
Copy link
Owner Author

Created a new issue for TODO: #193

@radomirbosak
Copy link
Owner Author

Remove/deprecate functions

This point was promoted to an issue #194

@radomirbosak
Copy link
Owner Author

Released in 0.19.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix fetching grammar data
1 participant