2017-01-01 20 views
1

まず、文章のサイズによっては、文章の小さなセット(200ms〜1sのオーダー)で解析が円滑に実行されています。Stanford Parser - MultiThreading issue - LexicalizedParser

達成したいのは何ですか?

1〜2時間で50Lの文章を解析したいと思います。マルチスレッドの呼び出しに>

  for(String sentence: sentences){ 
       Tree parsed = AnalysisUtilities.getInstance().parseSentence(job).parse; 
      } 

-

はどういうわけか、私はこれを変換する必要があります。 私はこのようになりますこれを行うには、マルチスレッドexecutorを、書いた - >

   MultiThreadExecutor<String> mte = new MultiThreadExecutor<String>(2, new JobExecutor<String>() { 
       @Override 
       public void executeJob(String job) { 
        Tree parsed = AnalysisUtilities.getInstance().parseSentence(job).parse; 
        inputTrees.add(parsed); 
       } 
      }, ""); 


      for(String sentence: sentences){ 
       mte.addJob(sentence); 
      } 

それは一つのスレッドに正常に動作しますが、できるだけ早く私は複数のスレッドを与えるとして、それはスタンフォード解析内部例外で破ります関数。例外は、次のようになります - >

java.lang.ArrayIndexOutOfBoundsException:java.util.ArrayList.add(ArrayList.java:441)で3 edu.stanford.nlp.parser.lexparser.BaseLexicon.initRulesWithWordで(BaseLexicon.java:300) at edu.stanford.nlp.parser.lexparser.BaseLexicon.isKnown(BaseLexicon.java:160) at edu.stanford.nlp.parser.lexparser.BaseLexicon.ruleIteratorByWord(BaseLexicon.java:212) edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.initializeChart(ExhaustivePCFGParser.java:1299) で) edu.stanでedu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.parse(ExhaustivePCFGParser.java:388) でford.nlp.parser.lexparser.LexicalizedParser.parse(LexicalizedParser.java:234) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.parse(LexicalizedParser.java:189) at edu.cmu.ark.AnalysisUtilities。 parseSentence(AnalysisUtilities.java:262) at edu.cmu.ark.QuestionAsker $ 1.executeJob(QuestionAsker.java:147) at edu.cmu.ark.QuestionAsker $ 1.executeJob(QuestionAsker.java:144) at edu。 cmu.ark.MultiThreadExecutor $ 1.run(MultiThreadExecutor.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java :615) at java.lang.Thread.run(Thread.java:745) java.lang.RuntimeException:依存関係が等しくない: "/*。/ CC " - >"。*。/ CC "は0を残し、" Spacious/CD " - >" easy/RB "は1 をedu.stanford.nlp.parser.lexparser.MLEDependencyGrammar.probTB(MLEDependencyGrammar.java: 586)EDUでedu.stanford.nlp.parser.lexparser.AbstractDependencyGrammar.scoreTB(AbstractDependencyGrammar.java:229) でedu.stanford.nlp.parser.lexparser.MLEDependencyGrammar.scoreTB(MLEDependencyGrammar.java:511) で。 (edible.png) (para) u.cmu.ark.QuestionAsker $ 1.executeJob(QuestionAsker.java:147) at edu.cmu.ark.QuestionAsker $ 1.executeJob(QuestionAsker.java:144) at edu.cmu.ark.MultiThreadExecutor $ 1.run(MultiThreadExecutor .java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor。Javaの:java.lang.Thread.runで615) (Thread.java:745) edu.stanford.nlp.parser.lexparser.BiLexPCFGParser.projectHooksでjava.lang.NullPointerExceptionが (BiLexPCFGParser.java:342) でedu.stanford.nlp.parser.lexparser.BiLexPCFGParser.processEdge(BiLexPCFGParser.java:546) at edu.stanford.nlp.parser.lexparser.BiLexPCFGParser.processItem(BiLexPCFGParser.java:571) at edu.stanford.nlp。 parser.lexparser.BiLexPCFGParser.parse(BiLexPCFGParser.java:854) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.parse(LexicalizedParser.java:255) at edu.stanford.nlp.parser.lexparser.LexicalizedParser。 parse(LexicalizedParser.java:189) at edu.cmu.ark.AnalysisUtilities.parseSentence(AnalysisUtilities.java:262) at edu.cmu.ark.QuestionAsker $ 1.executeJob(QuestionAsker.java:147) at edu.cmu.ark.QuestionAsker $ 1.executeJob(QuestionAsker.java:144) at edu.cmu.ark.MultiThreadExecutor $ 1.run (MultiThreadExecutor.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615) at java.lang .Thread.run(Thread.java:745)

これを行う方法はありますか?私は以前に尋ねたquestionに関係することができますが、いいえ。

答えて

1

ここでは、マルチスレッドモードでパーサを実行するコマンド例です:あなたはここで、同様にあなたのJavaコードでStanfordCoreNLPパイプラインを実行することができます

java -Xmx4g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse -parse.nthreads 4 -ssplit.eolonly -file some-sentences.txt -outputFormat text 
+0

はそれを行うにいくつかのドキュメント次のとおりです。http:/ /stanfordnlp.github.io/CoreNLP/api.html – StanfordNLPHelp

+0

新しいスタンフォードCoreNLP 3.7.0をダウンロードしてください。 – StanfordNLPHelp

関連する問題