Fixed #8516: Corrected typos in UK localflavor documentation
[django.git] / django / utils / stopwords.py
blob18aeb7f5d3898b9e8b19cfe57f51692a1de13396
1 # Performance note: I benchmarked this code using a set instead of
2 # a list for the stopwords and was surprised to find that the list
3 # performed /better/ than the set - maybe because it's only a small
4 # list.
6 stopwords = '''
9 an
10 are
15 for
16 from
17 how
24 that
25 the
26 this
28 was
29 what
30 when
31 where
32 '''.split()
34 def strip_stopwords(sentence):
35 "Removes stopwords - also normalizes whitespace"
36 words = sentence.split()
37 sentence = []
38 for word in words:
39 if word.lower() not in stopwords:
40 sentence.append(word)
41 return u' '.join(sentence)