【问题标题】:Finding how closely a set of strings are related找出一组字符串的相关程度
【发布时间】:2012-03-23 21:49:54
【问题描述】:

我有一个字符串数组(如示例所示)。我只是想找出其中最常见的。最常见的字符串定义为:- 如果 Apple Ipod touch 出现 10 次(比如说)而 Apple ipod 出现 8 次,那么我会说 Apple Ipod Touch 是所有元素中的主要/常见字符串。

Apple iPod touch, 8GB (with FaceTime Camera and Retina Display)
Aple Ipod Clasic 80gb 6th Generation Black
iPod classic 160GB - Silver
Apple 8GB iPod Touch
Apple Ipod Touch 8gb 4th Generation Mc540ll/a 8 Gb Newest Model
Apple iPod touch Black 4th Generation 8GB Touch Screen Wi-Fi MP3
Apple 8GB iPod touch�
Apple 8GB iPod touch MC540LL/A
Apple MC540LL/A - 8GB iPod Touch w/ Camera (4th Gen) (Newest Model)
Apple iPod Touch - 8 GB - Electronics
Apple iPod 8GB 4th Generation Black Touch
Apple iPod touch 8GB 4th Gen (Refurbished)
Apple Ipod Touch Digital Player - Apple Ios 5
Apple Ipod Touch 8G - White (4Th Gen)
Apple MC540LL/A iPod Touch 8GB (4th Generation)
(refurbished) Apple Ipod Touch 8gb (4th Generation)
Apple Ipod Touch 8Gb 4Th Generation
iPod Touch 8GB (4th Gen)
Apple Ipod Touch 32G - White (4Th Gen)
Apple iPod touch 8GB (4th Gen), White
Apple iPod touch White 4th Generation 8GB Touch Screen Wi-Fi MP3
Apple 32GB Black 4th Generation iPod Touch - MC544LL/A
Apple 8GB iPod touch�
Apple iPod touch 8GB - White - Electronics
Apple MC544LL/A - 32GB iPod Touch w/ Camera (4th Gen) (Newest Model)

那么,谁能建议我一些好的算法来做到这一点?问题是我没有任何标准/基准可以比较。我只需要比较所有元素之间,找出最常见的那个。这必须用 PHP 或 Javascript 实现。

希望我的问题很清楚。如果我在某处不清楚,请发表评论。

【问题讨论】:

  • 所以你想要出现在最多行中的子字符串(可能只有完整的单词数)?因为那将是Apple。还是您想要出现在多行中的最长子字符串?
  • 您要查找的字符串是整行还是其中的一部分?另外,您的搜索是否区分大小写?
  • 字符串应尽可能长且不区分大小写

标签: php javascript algorithm


【解决方案1】:

我不确定您是否使用过 PHP 的 similar_text 函数,或者是否有类似的 javascript 函数。一个快速的谷歌搜索也显示了我http://cambiatablog.wordpress.com/2011/03/25/algorithm-for-string-similarity-better-than-levenshtein-and-similar_text/

编辑:similar_text Javascript 函数! http://phpjs.org/functions/similar_text:902

【讨论】:

  • 我可以从上面的列表中生成一个建议列表吗?我应该使用什么算法?
猜你喜欢
  • 2010-10-09
  • 1970-01-01
  • 2012-12-22
  • 1970-01-01
  • 1970-01-01
  • 2011-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多