dmcc / PyStanfordDependencies

Python interface for converting Penn Treebank trees to Stanford Dependencies and Universal Depenencies
https://pypi.python.org/pypi/PyStanfordDependencies
68 stars 17 forks source link

Getting [Error 32] trying to parse tree from example #15

Closed MisterMeUA closed 7 years ago

MisterMeUA commented 8 years ago

Hello, David.

I'm getting Windows [Error 32] error when I'm trying to parse tree from example. Here is code:

sd = StanfordDependencies.get_instance(backend='subprocess') sent = sd.convert_tree('(S1 (NP (DT some) (JJ blue) (NN moose)))')

Next error shows Visual Studio: [Error 32] Ïðîöåñó íå âäàëîñÿ îòðèìàòè äîñòóï äî ôàéëó,: 'c:\users\sergiy\appdata\local\temp\tmpmd8c8k' *file name differs all the time

**I've tried to use another constructor, using jar_filename parameter - same exception

***I've tried to install JPypeBackend - it didn't help. It started failing when I was trying to call get_instance method.

Maybe i'm doing something wrong, but if there is problem, pleace take a look.

Thanks a lot)

dmcc commented 8 years ago

Thanks for the report @MisterMeUA! Does Visual Studio show you the full stack trace?

Also, it looks like your error messages are in another encoding/language. Do you know what your specific error message is? ("Ïðîöåñó íå âäàëîñÿ îòðèìàòè äîñòóï äî ôàéëó") From what I can tell, Error 32 on Windows can be several things.

MisterMeUA commented 8 years ago

Yep, sorry about "error message". I got message about process cannto access to file.

And full stacktrace:

Warning (from warnings module): File "C:\Python27\lib\site-packages\StanfordDependencies\StanfordDependencies.py", line 218 warnings.warn('Error importing JPypeBackend, ' UserWarning: Error importing JPypeBackend, falling back to SubprocessBackend.

Traceback (most recent call last): File "\DependExp.py", line 26, in sent = sd.convert_tree('(S1 (NP (DT some) (JJ blue) (NN moose)))') File "C:\Python27\lib\site-packages\StanfordDependencies\SubprocessBackend.py", line 100, in convert_tree return self.convert_trees([ptb_tree], **kwargs)[0] File "C:\Python27\lib\site-packages\StanfordDependencies\SubprocessBackend.py", line 80, in convert_trees os.remove(input_file.name) WindowsError: [Error 32] The process cannot access the file: 'c:\users\sergiy\appdata\local\temp\tmpvel74s'

dmcc commented 8 years ago

Thanks, that helps. Sounds like this might be related to #7 (which is strange since I thought #7 was closed). I'm afraid I won't be able to get to this for a couple weeks, but as a workaround, you might want to try replacing the os.remove(input_file.name) line (SubprocessBackend.py, line 80) with pass. This will result in the temporary files not getting deleted (not ideal), seems the better fix for Windows might be here.

MisterMeUA commented 8 years ago

Thanks for responce, but I cannot answer whether it helped for now. I'll answer as soon as I try proposed workaround.

MisterMeUA commented 8 years ago

Using "pass" helped for me, and it did make everythong working)

Thanks, David, for your responce and help)