duckduckgo/zeroclickinfo-spice — pull request #336 by jagtalon (2013-11-17 15:32:31+00:00)
Title: Forecast: Improve the relevancy on the front-end.

CC @yegg @moollaza

- Exit if `ddg-location` does not exist.
It might be reasonable to just exit if `ddg-location` does not exist in the API. For example, "emacs temp files" would display the weather result, but Forecast.io would say "Middle of Nowhere" when you click on the "More at ..." link. Here is the result of the query: http://cl.ly/image/3z0E3D2f223U, and here is Forecast.io when the link is clicked: http://cl.ly/image/0b2C0B1H3Q2g. Some legitimate queries are removed with this change such as the query "weather in libya", but Forecast.io would still say "Middle of Nowhere", and it might be a good trade-off given the number of false-positives that we get.

- Pass `ddg-location` to `DDG.stringsRelevant`.
Some queries would return irrelevant information, e.g., "weather in cebu" would return weather from "Monroe, OR". I was careful not to pass any zip codes into DDG.stringsRelevant, too, since we don't want to compare `ddg-location` with things like "07871".

- Make an exception if `DDG.stringsRelevant` results to `false`, and the query is a word in `ddg-location`.
The query "weather in ny" would actually return "New York, NY" in `ddg-location`. To accept queries like this, I added a regexp to check if \b(query)\b is in the query.