Last active 1764707069

Revision 363d2c830aad461f4a2435a070f422f1628a8fad

stopwords.py Raw
1def countwords(lst):
2 word_count = {}
3
4 for word in lst:
5 if word in word_count:
6 word_count[word] += 1
7 else:
8 word_count[word] = 1
9 return word_count
10
11def wordsOfLength(w, n):
12 result = []
13 for word, count in w.items():
14 if count >= n:
15 result.append(word)
16 return result
17
18def stopWords(text, k):
19 l = text.split()
20 w = countwords(l)
21 results = wordsOfLength(w, k)
22 return results
23
24