首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用标记器提取句子

使用标记器提取句子
EN

Stack Overflow用户
提问于 2015-04-07 06:01:08
回答 1查看 418关注 0票数 1

有一个比较两个字符串的简单代码,如果它包含一个关键字,它将执行一些操作。问题是,我希望在我检测到文本中的关键字之后,它会以某种方式提取出它所包含的句子。以下是代码:

代码语言:javascript
复制
String keyword="Keyword(S)";

StringTokenizer tokenizer =new StringTokenizer(text) ;

if(tokenizer.hasMoreTokens())
{
    tokenizer.nextToken();

    for(final String s :text.split(" ")){

        if(keyword.equals(s))
        {
            //get the whole sentence
        } 
    }
}

编辑:这里是一个示例:考虑到我们有以下文本:

代码语言:javascript
复制
    Text summarization is the process of extracting salient information from the source text and to present that
information to the user in the form of summary. It is very difficult for human beings to manually
summarize large documents of text. Automatic abstractive summarization provides the required solution
but it is a challenging task because it requires deeper analysis of text. In this paper, a survey on abstractive
text summarization methods has been presented. Abstractive summarization methods are classified into two
categories i.e. structured based approach and semantic based approach.

现在我们正在寻找包含单词abstractive的所有句子,然后返回这个句子。也许我们应该在到达一个.时存储一个令牌,然后每当我们找到关键字时,我们就使用这个标记来获取句子的开头,然后继续到到达另一个.,或者这听起来不合理?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-07 07:20:34

我认为您应该在.的基础上创建令牌,然后检查关键字如下:

代码语言:javascript
复制
    String keyword="summarization";
    StringTokenizer tokenizer =new StringTokenizer(text,"\\.") ;

     while(tokenizer.hasMoreTokens())
     {
             String x= tokenizer.nextToken();

              for(final String s :x.split(" ")){

               if(keyword.equals(s))
               {
                    System.out.println(x);
               } 
            }
     }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29484806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档