如何使用斯坦福解析器将文本分割成句子?

如何使用斯坦福解析器将文本或段落分割成句子?

是否有类似于getSentencesFromString()的方法来提取句子,就像Ruby中提供的那样?


回答:

你可以查看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);}

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注