I followed the instructions of installing SyntaxNet here in my Mac OS X Sierra 10.12.3.
I installed all the required software:
- python 2.7
- bazel (via
brew install bazel
) - swig (via
brew install swig
) - protocol buffers (via
pip install -U protobuf==3.0.0b2
) - mock (via
pip install mock
) - asciitree (via
pip install asciitree
) - numpy (via
pip install numpy
)
Then I build & test SyntaxNet:
git clone --recursive https://github.com/tensorflow/models.git
cd models/syntaxnet/tensorflow
./configure
cd ..
bazel test --linkopt=-headerpad_max_install_names \
syntaxnet/... util/utf8/...
The 6 tests failed during the process (expected as other users commented in the Github Issue list). As this is the expected behavior, I continue to run the first demo:
echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh
Expected result:
Input: Bob brought the pizza to Alice .
Parse:
brought VBD ROOT
+-- Bob NNP nsubj
+-- pizza NN dobj
| +-- the DT det
+-- to IN prep
| +-- Alice NNP pobj
+-- . . punct
But the following errors occurred:
Traceback (most recent call last):
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/__main__/syntaxnet/conll2tree.py", line 20, in <module>
import asciitree
ImportError: No module named asciitree
Traceback (most recent call last):
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/__main__/syntaxnet/parser_eval.py", line 23, in <module>
import tensorflow as tf
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 124, in <module>
from tensorflow.python.platform import test
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/platform/test.py", line 50, in <module>
import mock # pylint: disable=g-import-not-at-top,unused-import
ImportError: No module named mock
Traceback (most recent call last):
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/__main__/syntaxnet/parser_eval.py", line 23, in <module>
import tensorflow as tf
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 124, in <module>
from tensorflow.python.platform import test
File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/platform/test.py", line 50, in <module>
import mock # pylint: disable=g-import-not-at-top,unused-import
ImportError: No module named mock
The contents of demo.sh
are as follow:
#!/bin/bash
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# A script that runs a tokenizer, a part-of-speech tagger and a dependency
# parser on an English text file, with one sentence per line.
#
# Example usage:
# echo "Parsey McParseface is my favorite parser!" | syntaxnet/demo.sh
# To run on a conll formatted file, add the --conll command line argument.
#
PARSER_EVAL=bazel-bin/syntaxnet/parser_eval
MODEL_DIR=syntaxnet/models/parsey_mcparseface
[[ "$1" == "--conll" ]] && INPUT_FORMAT=stdin-conll || INPUT_FORMAT=stdin
$PARSER_EVAL \
--input=$INPUT_FORMAT \
--output=stdout-conll \
--hidden_layer_sizes=64 \
--arg_prefix=brain_tagger \
--graph_builder=structured \
--task_context=$MODEL_DIR/context.pbtxt \
--model_path=$MODEL_DIR/tagger-params \
--slim_model \
--batch_size=1024 \
--alsologtostderr \
| \
$PARSER_EVAL \
--input=stdin-conll \
--output=stdout-conll \
--hidden_layer_sizes=512,512 \
--arg_prefix=brain_parser \
--graph_builder=structured \
--task_context=$MODEL_DIR/context.pbtxt \
--model_path=$MODEL_DIR/parser-params \
--slim_model \
--batch_size=1024 \
--alsologtostderr \
| \
bazel-bin/syntaxnet/conll2tree \
--task_context=$MODEL_DIR/context.pbtxt \
--alsologtostderr
UPDATE sudo pip freeze
and pip freeze
return the same thing:
appdirs==1.4.3
asciitree==0.3.3
mock==2.0.0
numpy==1.12.0
packaging==16.8
pbr==2.0.0
protobuf==3.0.0b2
pyparsing==2.2.0
pyserial==3.2.1
six==1.10.0
tensorflow==1.0.1
tensorflow-gpu==1.0.1