0
私はスタンフォードCoreNLPを初めて利用しています。上記のタスクを実行する方法を私はタイプにしたいいくつかの文章がリストにそれら文字列の文章をキャスト持っており、それはannotation.set(CoreAnnotations.SentencesAnnotation.class, sentences);
SentencesAnnotation.classに独自の文章を設定するには
に設定されていますか?
私はスタンフォードCoreNLPを初めて利用しています。上記のタスクを実行する方法を私はタイプにしたいいくつかの文章がリストにそれら文字列の文章をキャスト持っており、それはannotation.set(CoreAnnotations.SentencesAnnotation.class, sentences);
SentencesAnnotation.classに独自の文章を設定するには
に設定されていますか?
あなたはList<CoreMap>
オブジェクトを記入する必要があります。以下のコードは、文章で文章を行う方法のヒントを提供します。しかし、他の分野がいっぱいになると、完全なコードを見つけることができます。here
List<String> yourSentences = ...;
int tokenOffset = 0;
List<CoreMap> sentences = new ArrayList<CoreMap>();
for(String s: yourSentences){
List<CoreLabel> tokenizedSentence = tokenizerFactory.getTokenizer(
new StringReader(s)).tokenize();
Annotation sentence = new Annotation(text.trim());
sentence.set(CoreAnnotations.TokensAnnotation.class, tokenizedSentence);
tokenOffset += sentenceTokens.size();
sentence.set(CoreAnnotations.TokenEndAnnotation.class, tokenOffset);
sentence.set(CoreAnnotations.SentenceIndexAnnotation.class, sentences.size());
sentences.add(sentence);
}
私はあなたの答えに示した同じリンクに従っています。私は文字列文を使用して、またはリスト文を使用して解析木を設定する必要があります。 –
iNikkz