【问题标题】:cleaning up noise words such as the, a, and or etc...清理噪音词,例如 the, a, and or etc...
【发布时间】:2012-06-02 10:51:08
【问题描述】:

我知道这是一个很长的机会,但我还是会问它。

我想对某些文本运行过滤器,并且我想删除英语中出现次数最多的单词,例如“The”、“a”、“and”、“or”等......

这个挑战是否在某个地方得到了解决,以便您可以得到一个相当不错的此类单词列表?

【问题讨论】:

  • 您是在询问在哪里可以找到这样的列表,或者如何从字符串中删除它们?无论哪种情况,我都会开始 herehere
  • 我更倾向于找到这样的列表。您的链接帮助很大。谢谢。

标签: php string parsing text stop-words


【解决方案1】:

您要查找的官方术语是“停用词”。对于英语,我经常使用 Solr 搜索引擎中的 stopwords.txt 列表:

https://code.google.com/p/solrmarc/source/browse/trunk/test/data/smoketest/solr/conf/stopwords.txt?r=1333

【讨论】:

  • 非常好。感谢您的起始链接,我能够找到更适合我的账单的这个。 webconfs.com/stop-words.php
  • 很高兴我能帮上忙。当您知道在 Google 上搜索哪些关键字时,总是会更容易。
【解决方案2】:

我会使用 str_replace()

例子:

str_replace("and", "", $text);

【讨论】:

    【解决方案3】:

    正则表达式怎么样?查看此页面的“单词”部分,http://www.roscripts.com/PHP_regular_expressions_examples-136.html。有一些示例正则表达式,包括对单词进行操作的模式。

    //Words: Whole word
    //Match one of the words from the list
    '\b(?:word1|word2|word3)\b'
    

    【讨论】:

      猜你喜欢
      • 2013-02-11
      • 2021-11-28
      • 1970-01-01
      • 1970-01-01
      • 2019-04-12
      • 1970-01-01
      • 2011-06-13
      • 2022-12-01
      • 1970-01-01
      相关资源
      最近更新 更多