demo.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Copyright 2016 Google Inc. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # ==============================================================================
  16. # A script that runs a tokenizer, a part-of-speech tagger and a dependency
  17. # parser on an English text file, with one sentence per line.
  18. #
  19. # Example usage:
  20. # echo "Parsey McParseface is my favorite parser!" | syntaxnet/demo.sh
  21. # To run on a conll formatted file, add the --conll command line argument.
  22. #
  23. PARSER_EVAL=bazel-bin/syntaxnet/parser_eval
  24. MODEL_DIR=syntaxnet/models/parsey_mcparseface
  25. [[ "$1" == "--conll" ]] && INPUT_FORMAT=stdin-conll || INPUT_FORMAT=stdin
  26. $PARSER_EVAL \
  27. --input=$INPUT_FORMAT \
  28. --output=stdout-conll \
  29. --hidden_layer_sizes=64 \
  30. --arg_prefix=brain_tagger \
  31. --graph_builder=structured \
  32. --task_context=$MODEL_DIR/context.pbtxt \
  33. --model_path=$MODEL_DIR/tagger-params \
  34. --slim_model \
  35. --batch_size=1024 \
  36. --alsologtostderr \
  37. | \
  38. $PARSER_EVAL \
  39. --input=stdin-conll \
  40. --output=stdout-conll \
  41. --hidden_layer_sizes=512,512 \
  42. --arg_prefix=brain_parser \
  43. --graph_builder=structured \
  44. --task_context=$MODEL_DIR/context.pbtxt \
  45. --model_path=$MODEL_DIR/parser-params \
  46. --slim_model \
  47. --batch_size=1024 \
  48. --alsologtostderr \
  49. | \
  50. bazel-bin/syntaxnet/conll2tree \
  51. --task_context=$MODEL_DIR/context.pbtxt \
  52. --alsologtostderr