i have a db with 3 tables review, pos and neg words for a film review im trying to detect if the word 'not' appears before a positive or negative word then add 1 to the pos count if it appears before a neg word ie this was not bad, and add 1 to the neg count if it appears before a pos word i.e this was not good
currently i have this method but it only seems to detect the not before a word once, how can i get it to detect through the whole text for example if i had, the film was not great, the acting was not good but it was not bad, the pos count should = 1 and neg count should = 2
Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
$find = $review_text;
if (preg_match("/(?<=not) $negwords/i", $find))
{
echo $good++;
}
if (preg_match("/(?<=not) $poswords/i", $find))
{
echo $bad++;
}