给定一个文档,选择一个相关的片段

BCS*_*BCS 10 statistics text-processing nlp heuristics

当我在这里问一个问题时,自动搜索返回的问题的工具提示给出了问题的第一点,但是它们中的相当一部分没有给出任何对理解问题更有用的文本而不是标题.有没有人知道如何制作一个过滤器来修剪问题的无用位?

我的第一个想法是修剪任何只包含某些列表中的单词的主要句子(例如,停止单词,加上标题中的单词,加上SO语料库中与标签具有非常弱相关性的单词,这同样可能是无论标签是什么,都会出现在任何问题中)

dmc*_*cer 16

自动文本摘要

听起来你对自动文本摘要很感兴趣.有关问题的详细概述,所涉及的问题以及可用的算法,请参阅Das和Martin的论文"自动文本摘要调查"(2007年).

简单算法

一种简单但相当有效的摘要算法是从原始文本中选择包含最频繁内容词的有限数量的句子(即,最常见的不包括停止列表词的句子).

Summarizer(originalText, maxSummarySize):
   // start with the raw freqs, e.g. [(10,'the'), (3,'language'), (8,'code')...]
   wordFrequences = getWordCounts(originalText)
   // filter, e.g. [(3, 'language'), (8, 'code')...]
   contentWordFrequences = filtStopWords(wordFrequences)
   // sort by freq & drop counts, e.g. ['code', 'language'...]
   contentWordsSortbyFreq = sortByFreqThenDropFreq(contentWordFrequences)

   // Split Sentences
   sentences = getSentences(originalText)

   // Select up to maxSummarySize sentences
   setSummarySentences = {}
   foreach word in contentWordsSortbyFreq:
      firstMatchingSentence = search(sentences, word)
      setSummarySentences.add(firstMatchingSentence)
      if setSummarySentences.size() = maxSummarySize:
         break

   // construct summary out of select sentences, preserving original ordering
   summary = ""
   foreach sentence in sentences:
     if sentence in setSummarySentences:
        summary = summary + " " + sentence

   return summary
Run Code Online (Sandbox Code Playgroud)

使用此算法进行汇总的一些开源软件包包括:

Classifier4J(Java)

如果您使用的是Java,则可以使用Classifier4J的模块SimpleSummarizer.

使用此处的示例,我们假设原始文本是:

Classifier4J是一个用于处理文本的java包.Classifier4J包括一个摘要.Summariser允许文本摘要.Summariser非常酷.我认为还没有其他java摘要.

如下面的代码片段所示,您可以轻松创建简单的一句话摘要:

// Request a 1 sentence summary
String summary = summariser.summarise(longOriginalText, 1);
Run Code Online (Sandbox Code Playgroud)

使用上面的算法,这将产生Classifier4J includes a summariser..

NClassifier(C#)

如果你正在使用C#,那么有一个名为NClassifier的Classifier4J到C#的端口

Tristan Havelick的NLTK总结器(Python)

有使用Python的内置Classifier4J的摘要装置的工作正在进行Python的港口自然语言工具包(NLTK)在这里.