Stanford and nltk parser analysis (regex matching?)

I am trying to use the Stanford parser with nltk, but this simple code

from nltk.parse.stanford import StanfordParser

parser = StanfordParser('stanford-parser.jar','stanford-parser-3.5-models.jar')

gives the following error

Traceback (most recent call last):
  File "temp_parser_new.py", line 4, in <module>
    parser = StanfordParser('stanford-parser.jar','stanford-parser-3.5-models.jar')
  File     "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nltk/parse/stanford.py", line 99, in __init__
key=lambda model_name: re.match(self._MODEL_JAR_PATTERN, model_name)
TypeError: unorderable types: NoneType() > _sre.SRE_Match()

Can you offer me a solution to this problem? Thanks!

Edit: Allowed with reboot.

+4
source share
1 answer

OK, I solved this problem. But he does not know the reason. On your line, "parser = StanfordParser('stanford-parser.jar','stanford-parser-3.5-models.jar')"delete the part .jar. And go to the folder with the file .jar. both uninstall .jar, then run your program.

0
source

Source: https://habr.com/ru/post/1606671/


All Articles