|
1 | 1 | import os |
2 | 2 | import sys |
3 | | - |
| 3 | +import time |
4 | 4 | import asciitree |
5 | 5 | import collections |
6 | 6 |
|
7 | 7 | from concurrent.futures import ThreadPoolExecutor |
8 | 8 |
|
9 | 9 | PROJECT_ROOT = os.getcwd() |
| 10 | + |
10 | 11 | runfiles_path = os.path.join(PROJECT_ROOT, 'models', 'syntaxnet', 'bazel-bin', 'syntaxnet', 'parser_eval.runfiles') |
11 | 12 | tensorflow_path = os.path.join(PROJECT_ROOT, 'models', 'syntaxnet', 'bazel-bin', 'syntaxnet', 'parser_eval.runfiles', |
12 | 13 | 'external', 'tf') |
13 | 14 |
|
14 | 15 | sys.path.append(runfiles_path) |
15 | 16 | sys.path.append(tensorflow_path) |
16 | 17 |
|
17 | | -import os.path |
18 | | -import time |
19 | | - |
20 | 18 | import tensorflow as tf |
21 | | - |
22 | | -from tensorflow.python.platform import gfile |
23 | 19 | from tensorflow.python.platform import tf_logging as logging |
24 | | -from syntaxnet import sentence_pb2 |
25 | | -from syntaxnet import graph_builder |
26 | | -from syntaxnet import structured_graph_builder |
| 20 | +from syntaxnet import sentence_pb2, structured_graph_builder |
27 | 21 | from syntaxnet.ops import gen_parser_ops |
28 | 22 |
|
29 | | -# from io import TextIOWrapper, BytesIO |
30 | | -# from StringIO import StringIO |
31 | | -# from subprocess import Popen, PIPE, STDOUT |
32 | | - |
33 | | -# CURRENT_PATH = os.getcwd() |
34 | | -# other_option = os.path.dirname(os.path.realpath(__file__)) |
35 | | -# print("current_path=%s, other_option=%s", CURRENT_PATH, other_option) |
36 | | - |
37 | | -# runfiles_path = os.path.join(CURRENT_PATH, 'models', 'syntaxnet', 'bazel-bin', 'syntaxnet', 'parser_eval.runfiles') |
38 | | -# sys.path.append(runfiles_path) |
39 | | - |
40 | | -# TODO: which of these paths is actually needed? |
41 | | -# sys.path.append(CURRENT_PATH + '/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles') |
42 | | -# sys.path.append(os.path.join(CURRENT_PATH, 'models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/')) |
43 | | -# sys.path.append('/Users/plowman/projects/parseface/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/') |
44 | | -# sys.path.append( |
45 | | -# '/Users/plowman/projects/parseface/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/six_archive') |
46 | | - |
47 | | -# tensorflow_path = os.path.join(CURRENT_PATH, 'models', 'syntaxnet', 'bazel-bin', 'syntaxnet', 'parser_eval.runfiles', |
48 | | -# 'external', 'tf') |
49 | | -# |
50 | | -# sys.path.append(tensorflow_path) |
51 | | -# sys.path.append( |
52 | | -# '/Users/plowman/projects/parseface/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf') |
53 | | - |
54 | | - |
55 | | -project_root = os.path.dirname(os.path.realpath(__file__)) |
56 | | -input_file_path = os.path.join(project_root, "input-file.txt") |
57 | | -output_file_path = os.path.join(project_root, "output-file.txt") |
58 | | -parser_path = os.path.join(project_root, 'models', 'syntaxnet', 'bazel-bin', 'syntaxnet', 'parser_eval') |
59 | | -mcparseface_path = os.path.join(project_root, 'models', 'syntaxnet', 'syntaxnet', 'models', 'parsey_mcparseface') |
| 23 | + |
| 24 | +input_file_path = os.path.join(PROJECT_ROOT, "input-file.txt") |
| 25 | +output_file_path = os.path.join(PROJECT_ROOT, "output-file.txt") |
| 26 | +parser_path = os.path.join(PROJECT_ROOT, 'models', 'syntaxnet', 'bazel-bin', 'syntaxnet', 'parser_eval') |
| 27 | +mcparseface_path = os.path.join(PROJECT_ROOT, 'models', 'syntaxnet', 'syntaxnet', 'models', 'parsey_mcparseface') |
60 | 28 | tagger_params_path = os.path.join(mcparseface_path, 'tagger-params') |
61 | 29 | parser_params_path = os.path.join(mcparseface_path, 'parser-params') |
62 | | -task_context_path = os.path.join(project_root, "custom_context.pbtxt") |
| 30 | +task_context_path = os.path.join(PROJECT_ROOT, "custom_context.pbtxt") |
63 | 31 |
|
64 | 32 | """ |
65 | 33 | PARSER_EVAL=bazel-bin/syntaxnet/parser_eval |
@@ -158,7 +126,6 @@ def _get_sentence_dict(): |
158 | 126 | result_dict = None |
159 | 127 | while True: |
160 | 128 | documents, finished = sess.run(src) |
161 | | - logging.info('Read %d documents', len(documents)) |
162 | 129 | for d in documents: |
163 | 130 | sentence.ParseFromString(d) |
164 | 131 | d = to_dict(sentence) |
@@ -273,13 +240,6 @@ def _perform_action(action=None): |
273 | 240 | logging.info('Seconds elapsed in evaluation: %.2f, ' |
274 | 241 | 'eval metric: %.2f%%', time.time() - t, eval_metric) |
275 | 242 |
|
276 | | - |
277 | | - # with open(output_file_path, mode="w") as output_file: |
278 | | - # output_file.write(".") |
279 | | - |
280 | | - # with open(output_file_path, mode="r") as output_file: |
281 | | - # print output_file.read() |
282 | | - |
283 | 243 | """ |
284 | 244 | /usr/local/bin/python /Users/plowman/projects/parseface/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/syntaxnet/parser_eval.py |
285 | 245 | --input=stdin --output=stdout-conll --hidden_layer_sizes=64 --arg_prefix=brain_tagger |
|
0 commit comments