2012-03-23 8 views
2

私は文字列の配列を持っています(例を参照)。私はちょうどそれらの間で最も一般的なものを見つけることを望む。最も一般的な文字列は次のように定義されています: - リンゴのiPodが8回表示されている間にアップルのiPod touchが10回表示されている場合、アップルの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で実装する必要があります。

私は私の質問ではっきりしています。私がどこかに不明な場合はコメントしてください。

+0

したがって、ほとんどの行に表示される部分文字列(たぶん完全な単語数のみ)が必要ですか?それは「Apple」だろうから。または、複数の行に表示される最長の部分文字列が必要ですか? – biziclop

+0

探している文字列は、全体の行またはその一部ですか?また、検索で大文字と小文字が区別されるかどうかは? –

+0

文字列はできるだけ長く、大文字小文字を区別しないでください –

答えて

2

PHPのsimilar_text機能を使用しているかどうか、または同様のjavascript機能があるかどうかはわかりません。簡単なGoogle検索でも私に表示されましたhttp://cambiatablog.wordpress.com/2011/03/25/algorithm-for-string-similarity-better-than-levenshtein-and-similar_text/

EDIT:similar_text Javascript機能! http://phpjs.org/functions/similar_text:902

+0

上記リストの中から提案リストを生成できますか?私はそれにどのようなアルゴリズムを使用すべきですか? –

関連する問題