function word_counts ($text, $noise
{
$words = preg_split'/[^A-Za-z]+/', strtolower$text));
$counts = array();
foreach ($words as $word) {
if (strlen$word)>1) { // 1-letter words are ignored
if (array_search$word, $noise)===false) { // noise word?
if (array_key_exists$word, $counts)) {
$counts$word] = $counts$word]+1;
} else {
$counts$word] = 1;
}
}
}
}
return $counts
}