GET_subreddits_by_topic: don't search for common words.

This commit is contained in:
Brian Simpson
2015-03-03 23:39:01 -05:00
parent 5fa292852f
commit ba5931f54c

View File

@@ -4047,6 +4047,24 @@ class ApiController(RedditController):
if not query or len(query) < 2:
return []
# http://en.wikipedia.org/wiki/Most_common_words_in_English
common_english_words = {
'the', 'be', 'to', 'of', 'and', 'in', 'that', 'have', 'it', 'for',
'not', 'on', 'with', 'he', 'as', 'you', 'do', 'at', 'this', 'but',
'his', 'by', 'from', 'they', 'we', 'say', 'her', 'she', 'or', 'an',
'will', 'my', 'one', 'all', 'would', 'there', 'their', 'what', 'so',
'up', 'out', 'if', 'about', 'who', 'get', 'which', 'go', 'me',
'when', 'make', 'can', 'like', 'time', 'no', 'just', 'him', 'know',
'take', 'people', 'into', 'year', 'your', 'good', 'some', 'could',
'them', 'see', 'other', 'than', 'then', 'now', 'look', 'only',
'come', 'its', 'over', 'think', 'also', 'back', 'after', 'use',
'two', 'how', 'our', 'work', 'first', 'well', 'way', 'even', 'new',
'want', 'because', 'any', 'these', 'give', 'day', 'most', 'us',
}
if query.lower() in common_english_words:
return []
exclude = Subreddit.default_subreddits()
faceting = {"reddit":{"sort":"-sum(text_relevance)", "count":20}}