spring如何在Java中找到给定段落的标题
我想创建一些功能,可以为我提供给定聊天对话或段落的标题。 这里的标题是“聊天内容”或段落内容
我尝试了StanfordCoreNLP来实现句子标记化和句子识别器。但我的主要目标是从段落或输入文本中搜索一些关键字,并确定输入文本的实际标题或标题是什么
我试过这个-
public class Pipeline {
private static Properties properties;
private static String propertiesName = "tokenize, ssplit, pos, lemma, parse, sentiment, ner";
private static StanfordCoreNLP stanfordCoreNLP;
private Pipeline(){
}
static {
properties = new Properties();
properties.setProperty("annotators", propertiesName);
}
public static StanfordCoreNLP getPipeline(){
if(stanfordCoreNLP == null){
stanfordCoreNLP = new StanfordCoreNLP(properties);
}
return stanfordCoreNLP;
} }
句子识别器。爪哇-
public class SentenceRecognizer {
public static void main(String[] args) {
StanfordCoreNLP stanfordCoreNLP= Pipeline.getPipeline();
String text = "Hey Iam Jhon. Iam doing Math. I like coffee ";
CoreDocument coreDocument = new CoreDocument(text);
stanfordCoreNLP.annotate(coreDocument);
List<CoreSentence> sentences= coreDocument.sentences();
for(CoreSentence sentence: sentences){
System.out.println(sentence.toString());
}
}
}
输出-
Hey Iam Jhon.
Iam doing Math.
I like coffee
同样,我也实现了标记化、词性、情绪分析和引理
我想要的输出- 示例段落为输入-
If you could make a holiday, what would it be like? What traditions would it have? What would people eat on your holiday?
预期输出-假日
任何人都可以在逻辑上帮助我,使用所有这些从这个字符串生成标题。请帮忙
共 (0) 个答案