非常に単純な方法は、一般的なストップワードをテキストから削除して、「標準」、「JSON」などのより意味のある単語を残すことです。ただし、それでも多くのノイズが発生するため、OpenCalaisのようなサービスを検討してください。テキストのかなり洗練された分析を行います。
アップデート:
さて、私の以前の回答のリンクは実装を指していましたが、あなたはそれを求めたので、簡単なものはここにあります:
function stopWords($text, $stopwords) {
// Remove line breaks and spaces from stopwords
$stopwords = array_map(function($x){return trim(strtolower($x));}, $stopwords);
// Replace all non-word chars with comma
$pattern = '/[0-9\W]/';
$text = preg_replace($pattern, ',', $text);
// Create an array from $text
$text_array = explode(",",$text);
// remove whitespace and lowercase words in $text
$text_array = array_map(function($x){return trim(strtolower($x));}, $text_array);
foreach ($text_array as $term) {
if (!in_array($term, $stopwords)) {
$keywords[] = $term;
}
};
return array_filter($keywords);
}
$stopwords = file('stop_words.txt');
$text = "Requirements - Working knowledge, on LAMP Environment using Linux, Apache 2, MySQL 5 and PHP 5, - Knowledge of Web 2.0 Standards - Comfortable with JSON - Hands on Experience on working with Frameworks, Zend, OOPs - Cross Browser Javascripting, JQuery etc. - Knowledge of Version Control Software such as sub-version will be preferable.";
print_r(stopWords($text, $stopwords));
stop_word.txt
これと、このGistの内容を見ることができます。
サンプル テキストで上記を実行すると、次の配列が生成されます。
Array
(
[0] => requirements
[4] => linux
[6] => apache
[10] => mysql
[13] => php
[25] => json
[28] => frameworks
[30] => zend
[34] => browser
[35] => javascripting
[37] => jquery
[38] => etc
[42] => software
[43] => preferable
)
したがって、私が言ったように、これはやや素朴で、より多くの最適化を使用することができます (さらに遅い) が、テキストからより関連性の高いキーワードを引き出します。ストップワードも微調整する必要があります。のような用語をキャプチャするのWeb 2.0
は非常に難しいので、テキストを理解してエンティティと参照のリストを返すことができる OpenCalais のような本格的なサービスを使用する方がよいと思います。DocumentCloudは、まさにこのサービスに依存して、ドキュメントから情報を収集します。
また、クライアント側の実装では、JavaScript を使用してほぼ同じことを行うことができ、おそらくはるかにクリーンになります (ただし、クライアントにとっては遅くなる可能性があります)。