apertium / apertium-python

now you can even use apertium from python
GNU General Public License v3.0
31 stars 27 forks source link

Improved __repr__/__str__ for Analyzer/Generator/Translator #25

Open sushain97 opened 6 years ago

sushain97 commented 6 years ago

I'm not sure what they are now but they're probably not too helpful

orgh0 commented 6 years ago

@sushain97

In [1]: import apertium

In [2]: a = apertium.Analyzer('en')

In [3]: a
Out[3]: Analyzer(mode=eng-morph, lang=eng)

Is the structure okay ?

sushain97 commented 6 years ago

Ideally, __repr__ would recreate the class. So, repr(a) == "Analyzer(lang='eng')" and str(a) == "<Analyzer: eng-morph>" seems nice.

orgh0 commented 6 years ago

@sushain97 what about for the Translator module? I don't have mode there. we just parse mode files in that module. What should the __str__() have?

sushain97 commented 6 years ago

There is a mode. It's something like spa-cat_valencia. The fact that we're parsing a mode implies there is one.