I've installed syntaxnet and am able to run the parser with the provided demo script. Ideally, I would like to run it directly from python. The only code I found was this:
import subprocess
import os
os.chdir(r"../models/syntaxnet")
subprocess.call([
"echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh"
], shell = True)
which is a complete disaster - inefficient and over-complex (calling python from python should be done with python).
How can I call the python APIs directly, without going through shell scripts, standard I/O, etc?
EDIT - Why isn't this as easy as opening syntaxnet/demo.sh and reading it?
This shell script calls two python scripts (parser_eval and conll2tree) which are written as python scripts and can't be imported into a python module without causing multiple errors. A closer look yields additional script-like layers and native code. These upper layers need to be refactored in order to run the whole thing in a python context. Hasn't anyone forked syntaxnet with such a modification or intend to do so?
The best way to integrate SyntaxNet with your own code is to have it as a web service. I did that to parse Portuguese text.
I started by adapting an existing Docker Container with SyntaxNet and Tensorflow serving, to run only for Portuguese, to keep memory low. It runs really fast and it's easy to integrate with your code.
I did a blog post about it, and you can easily adapt it to any other language:
http://davidsbatista.net/blog/2017/07/22/SyntaxNet-API-Portuguese/