【发布时间】:2016-02-10 00:06:36
【问题描述】:
我想知道如何使用 StanfordCoreNLP 在段落中找到句子的开始和结束位置。现在我正在使用 DocumentPreprocessor 将段落拆分为句子。是否可以得到句子在原文中实际所在位置的起止索引?
我正在使用此处提出的另一个问题的代码。
String paragraph = "My 1st sentence. “Does it work for questions?” My third sentence.";
Reader reader = new StringReader(paragraph);
DocumentPreprocessor dp = new DocumentPreprocessor(reader);
List<String> sentenceList = new ArrayList<String>();
for (List<HasWord> sentence : dp) {
String sentenceString = Sentence.listToString(sentence);
sentenceList.add(sentenceString.toString());
}
for (String sentence : sentenceList) {
System.out.println(sentence);
}
取自:How can I split a text into sentences using the Stanford parser?
谢谢
【问题讨论】:
标签: java indexing split stanford-nlp sentence