/yufa

Yet another attempt to create a natural language description language :cool:

Primary LanguagePython

yǔfǎ 语法 grammar

This is still beta software. As such you should assume that the schema can and will change.

introduction

yufa is my latest attempt to try to make a more human-readable natural language grammar description framework. I say more human-readable cause GrammaticalFramework is technically human readable. It is also driven by my desire to codeify the rules to conjugation and declension as I learn them and have a method of validating that I have in fact learned the rules correctly.

how to design a grammar

TODO :)

how to run

visual model

yufa uses textX to parse the description language. It also has some great visualization tools, with the help of graphviz (which provides the dot program).

>>> from textx.export import model_export
>>> meta  = metamodel_from_file('Rules.tx')
>>> model = meta.model_from_file('{path to ruleset}')
>>> model_export(model, 'program.dot')
$ dot -Tpng program.dot -O program.dot.png

command line

python parser.py {language} {word} {pronoun} {ruleset} {additional args}[optional]

If an additional arg is prefixed with a + it is treated as a suffix. Ex. +REFL would be treated as the reflexive suffix (assuming it is defined) and added after the verb is conjugated.

For example:

  • python parser.py dutch nemen 1sg prs will result in neem.
  • python parser.py lithuanian dirba 1sg prs A will result in dirbu. The A indicates that the verb dirbti (seen there in the 3 person present form) is an A class verb.
  • python parser.py russian работать 1sg prs will result in работаю.
  • python parser.py russian говорить 1pl prs +REFL will result in говоримся.

testing

Tests with nose: python -m nose2