【问题标题】:What techniques/tools are there for discovering common phrases in chunks of text?有哪些技术/工具可用于发现文本块中的常用短语?
【发布时间】:2010-11-28 10:09:21
【问题描述】:

假设我有 100000 个电子邮件正文,其中 2000 个包含一个随意的常见字符串,例如“the quick brown fox jumps over the lazy dog”或“lorem ipsum dolor sit amet”。我可以/应该使用什么技术来“挖掘”这些短语?我对挖掘单个单词或短语不感兴趣。我还需要过滤掉所有邮件中我已经知道的短语。

例子:

string mailbody1 = "Welcome to the world of tomorrow! This is the first mail body. Lorem ipsum dolor sit AMET. Have a nice day dude. Cya!";
string mailbody2 = "Welcome to the world of yesterday! Lorem ipsum dolor sit amet Please note this is the body of the second mail. Have a nice day.";
string mailbody3 = "A completely different body.";
string[] mailbodies = new[] {mailbody1, mailbody2, mailbody3};
string[] ignoredPhrases = new[] {"Welcome to the world of"};

string[] results = DiscoverPhrases(mailbodies, ignoredPhrases);

在本例中,我希望 DiscoverPhrases 函数返回“lorem ipsum dolor sit amet”和“祝你有美好的一天”。如果该函数还返回较短的“噪音”短语,这并不重要,但如果可能的话,最好在此过程中消除这些。

编辑:我忘记在示例中包含 mailbody3。

【问题讨论】:

    标签: .net data-mining


    【解决方案1】:

    看看N-grams。最常见的短语必然会贡献最常见的 N-gram。我会从单词三元组开始,看看它会导致什么。 (所需的空间是文本长度的 N 倍,所以你不能让 N 变得太大。)如果你保存位置而不仅仅是计数,你然后可以查看三元组是否可以扩展为常用短语。

    【讨论】:

      【解决方案2】:

      我不确定这是否是您想要的,但请查看 longest common substring problemdiff utility algorithms.

      【讨论】:

        【解决方案3】:

        这样的方法可能会奏效,具体取决于您是否关心单词边界。在伪代码中(其中LCS 是用于计算Longest Common Subsequence 的函数):

        someMinimumLengthParameter = 20;
        foundPhrases = [];
        
        do {
            lcs = LCS(mailbodies);
            if (lcs in ignoredPhrases) continue;
        
            foundPhrases += lcs;
        
            for body in mailbodies {
                body.remove(lcs);
            }    
        } while(lcs.length > someMinimumLengthParameter);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-04-30
          • 1970-01-01
          • 1970-01-01
          • 2011-07-06
          • 1970-01-01
          • 2010-09-14
          • 2010-09-25
          • 1970-01-01
          相关资源
          最近更新 更多