一个非常幼稚的方法是去除常见stopwords从文本,让你与像“标准”,“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));
你可以看到这一点,和在此Gist的stop_word.txt
内容。
运行上面的你的示例文本生成以下数组:
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,而且可能更清洁的(虽然它可能是客户端慢。)
感谢您的链接,我期待这样的事情。我尝试了YQL,但不知何故它并没有认识到很多条款。找到这个名为Zemanta的网站,这有点不错,我打算使用这两个网站并合并我的结果。 – sgomez 2011-01-29 17:42:26
这是我在互联网上发现的最棒的东西,用了5年左右......谢谢 – AMB 2014-07-24 05:37:49