Stanford3.8.0依存句法分析在java中运行



linux 下的Stanford词性标注

java -mx1g -cp "/home/hadoop/stanford-corenlp-full-2017-06-09/stanford-postagger.jar:" edu.stanford.nlp.tagger.maxent.MaxentTagger -model "/home/hadoop/stanford-corenlp-full-2017-06-09/models/chinese-distsim.tagger" -textFile source.txt > result-linux.txt


win7下的Stanford 依存句法分析
java -mx150m -cp "*;" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "penn,typedDependencies" lexparser/chinesePCFG.ser.gz source.txt > my.txt

linux 下的Stanford 依存句法分析


java -mx150m -cp "/home/hadoop/stanford-parser-full-2017-06-09/*:" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "penn,typedDependencies" lexparser/chinesePCFG.ser.gz   source.txt > my.txt

(ROOT
  (IP
    (NP (NR 张传庆))
    (VP
      (ADVP (AD 曾))
      (PP (P 在)
        (LCP
          (NP
            (QP (CD 许多))
            (NP (NR 中国) (NN 引水) (NN 隧洞) (NN 项目)))
          (LC 中)))
      (VP (VV 发挥)
        (NP
          (ADJP (JJ 重要))
          (NP (NN 作用。)))))))

nsubj(发挥-10, 张传庆-1)
advmod(发挥-10, 曾-2)
case(项目-8, 在-3)
dep(项目-8, 许多-4)
compound:nn(项目-8, 中国-5)
compound:nn(项目-8, 引水-6)
compound:nn(项目-8, 隧洞-7)
nmod:prep(发挥-10, 项目-8)
case(项目-8, 中-9)
root(ROOT-0, 发挥-10)
amod(作用。-12, 重要-11)
dobj(发挥-10, 作用。-12)


去掉penn
java -mx150m -cp "/home/hadoop/stanford-parser-full-2017-06-09/*:" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "typedDependencies" lexparser/chinesePCFG.ser.gz   source.txt > my.txt
只显示penn
输出:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Parsing file: source.txt
Parsing [sent. 1 len. 12]: 张传庆 曾 在 许多 中国 引水 隧洞 项目 中 发挥 重要 作用。
Parsed file: source.txt [1 sentences].
Parsed 12 words in 1 sentences (7.22 wds/sec; 0.60 sents/sec).
hadoop@master:~/stanford-parser-full-2017-06-09$ cat my.txt
nsubj(发挥-10, 张传庆-1)
advmod(发挥-10, 曾-2)
case(项目-8, 在-3)
dep(项目-8, 许多-4)
compound:nn(项目-8, 中国-5)
compound:nn(项目-8, 引水-6)
compound:nn(项目-8, 隧洞-7)
nmod:prep(发挥-10, 项目-8)
case(项目-8, 中-9)
root(ROOT-0, 发挥-10)
amod(作用。-12, 重要-11)
dobj(发挥-10, 作用。-12)

java -mx150m -cp "/home/hadoop/stanford-parser-full-2017-06-09/*:" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "penn" lexparser/chinesePCFG.ser.gz   source.txt > my.txt

输出
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Parsing file: source.txt
Parsing [sent. 1 len. 12]: 张传庆 曾 在 许多 中国 引水 隧洞 项目 中 发挥 重要 作用。
Parsed file: source.txt [1 sentences].
Parsed 12 words in 1 sentences (20.76 wds/sec; 1.73 sents/sec).
hadoop@master:~/stanford-parser-full-2017-06-09$ cat my.txt
(ROOT
  (IP
    (NP (NR 张传庆))
    (VP
      (ADVP (AD 曾))
      (PP (P 在)
        (LCP
          (NP
            (QP (CD 许多))
            (NP (NR 中国) (NN 引水) (NN 隧洞) (NN 项目)))
          (LC 中)))
      (VP (VV 发挥)
        (NP
          (ADJP (JJ 重要))
          (NP (NN 作用。)))))))






原文地址:https://www.cnblogs.com/herosoft/p/8135179.html