forked from ljm625/syntaxnet-rest-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_parse.sh
68 lines (66 loc) · 1.85 KB
/
custom_parse.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# A script that runs a morphological analyzer, a part-of-speech tagger and a
# dependency parser on a text file, with one sentence per line.
#
# Example usage:
# bazel build syntaxnet:parser_eval
# cat sentences.txt |
# syntaxnet/models/parsey_universal/parse.sh \
# $MODEL_DIRECTORY > output.conll
#
# To run on a conll formatted file, add the --conll command line argument:
# cat sentences.conll |
# syntaxnet/models/parsey_universal/parse.sh \
# --conll $MODEL_DIRECTORY > output.conll
#
# Models can be downloaded from
# http://download.tensorflow.org/models/parsey_universal/<language>.zip
# for the languages listed at
# https://github.com/tensorflow/models/blob/master/syntaxnet/universal.md
#
PARSER_EVAL=bazel-bin/syntaxnet/parser_eval
CONTEXT=syntaxnet/models/parsey_universal/context.pbtxt
if [[ "$1" == "--conll" ]]; then
INPUT_FORMAT=stdin-conll
shift
else
INPUT_FORMAT=stdin
fi
MODEL_DIR=$1
$PARSER_EVAL \
--input=$INPUT_FORMAT \
--output=stdout-conll \
--hidden_layer_sizes=64 \
--arg_prefix=brain_morpher \
--graph_builder=structured \
--task_context=$CONTEXT \
--resource_dir=$MODEL_DIR \
--model_path=$MODEL_DIR/morpher-params \
--slim_model \
--batch_size=1024 \
--alsologtostderr \
| \
$PARSER_EVAL \
--input=stdin-conll \
--output=stdout-conll \
--hidden_layer_sizes=64 \
--arg_prefix=brain_tagger \
--graph_builder=structured \
--task_context=$CONTEXT \
--resource_dir=$MODEL_DIR \
--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=$CONTEXT \
--resource_dir=$MODEL_DIR \
--model_path=$MODEL_DIR/parser-params \
--slim_model \
--batch_size=1024 \
--alsologtostderr