如何使用斯坦福解析器将段落拆分为句子?
0 1060
0
该提问暂无详细描述
收藏
2021-01-17 11:00 更新 gitvrar •  465
共 1 个回答
高赞 时间
0

可以检查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) {
   // SentenceUtils not Sentence
   String sentenceString = SentenceUtils.listToString(sentence);
   sentenceList.add(sentenceString);
}

for (String sentence : sentenceList) {
   System.out.println(sentence);
}

收藏
2021-01-17 11:02 更新 同步 •  1732