duckduckgo/duckduckgo — pull request #48 by moollaza (2013-10-30 00:44:43+00:00)
Title: fixed bug affecting trigger phrases

/cc @yegg @russellholt @jagtalon @nilnilnil

This fixes #44.

After very carefully walking through this file I believe I finally understand it, which led me to find the bug, being an index problem.

This line is meant to find the position of the words in front/behind the current word, to check if the query matches the given trigger phrase.

The incorrect index adjustment was causing the script to search 2 words before the query word, rather than directly
in front of the word and it happened to match in this case.

```
0 1 2 3 4
the book of joe review
```

The range is supposed to indicate that the words before "review" are at index 3, but instead because of adjusting the index in the wrong direction, it was matching against each word from index 1-3, with "review" to see if they make a trigger phrase and coincidentally position 1, "book" + "review" makes a trigger, so the query looked as though it contained the word "book review"

At this point in the execution, `$cnt == 4` (review is index 4) and `word_count == 2` (the candidate trigger phrase, "book review" contains 2 words).