learn-teochew / parsetc

Parse and convert between different Teochew romanization systems
https://learn-teochew.github.io/parsetc/
MIT License
0 stars 1 forks source link

Basic example doesn't work in python 3.9 env. #4

Closed thejsj closed 1 year ago

thejsj commented 1 year ago

Hi! Using the basic example, but it seems it doesn't work. Tried to do a little poking, but didn't dig too much into the lark declartions.

$ echo 'ua2 ain3 oh8 diê5ghe2, ain3 dan3 diê5ziu1 uê7.' | python3.9 ./parsetc.py -i gdpi -o tlo                     8:08
Traceback (most recent call last):
  File "/Users/jsilva/Library/Python/3.9/lib/python/site-packages/lark/visitors.py", line 124, in _call_userfunc
    return f(children)
  File "/Users/jsilva/figma/parsetc/translit.py", line 186, in word_sep
    return('-'.join([i for i in items if i != '-']))
TypeError: sequence item 1: expected str instance, NoneType found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jsilva/figma/parsetc/./parsetc.py", line 366, in <module>
    outtext = transliterate(intext, i=args.input, o=args.output, superscript_tone=args.superscript_tone)
  File "/Users/jsilva/figma/parsetc/./parsetc.py", line 274, in transliterate
    out = TRANSFORMER_DICT[o].transform(t)
  File "/Users/jsilva/Library/Python/3.9/lib/python/site-packages/lark/visitors.py", line 161, in transform
    return self._transform_tree(tree)
  File "/Users/jsilva/Library/Python/3.9/lib/python/site-packages/lark/visitors.py", line 156, in _transform_tree
    children = list(self._transform_children(tree.children))
  File "/Users/jsilva/Library/Python/3.9/lib/python/site-packages/lark/visitors.py", line 146, in _transform_children
    res = self._transform_tree(c)
  File "/Users/jsilva/Library/Python/3.9/lib/python/site-packages/lark/visitors.py", line 157, in _transform_tree
    return self._call_userfunc(tree, children)
  File "/Users/jsilva/Library/Python/3.9/lib/python/site-packages/lark/visitors.py", line 128, in _call_userfunc
    raise VisitError(tree.data, tree, e)
lark.exceptions.VisitError: Error trying to process rule "word_sep":

sequence item 1: expected str instance, NoneType found
kbseah commented 1 year ago

Thanks for reporting this issue. I wasn't able to reproduce your error. I'm using Python 3.9.7, but my version of lark is 0.11.3 because this was developed some time ago. Could you try pinning the lark version in a venv or a Conda environment?

kbseah commented 1 year ago

Should be fixed now with packaging for PyPI, correct lark version should be pulled by setuptools

kbseah commented 6 months ago

hi @thejsj wanted to let you know that i've updated the package to use lark v1. am planning a bunch of other improvements, too