diff --git a/app/WordFreq.py b/app/WordFreq.py old mode 100644 new mode 100755 index 3620a41..eaf48c8 --- a/app/WordFreq.py +++ b/app/WordFreq.py @@ -2,24 +2,24 @@ # Copyright 2019 (C) Hui Lan # Written permission must be obtained from the author for commercial uses. ########################################################################### - from wordfreqCMD import remove_punctuation, freq, sort_in_descending_order import string + class WordFreq: - def __init__(self, s): + def __init__(self, s, max_word_length=30): self.s = remove_punctuation(s) + self.max_word_length = max_word_length def get_freq(self): lst = [] - for t in freq(self.s): + for t in freq(self.s, self.max_word_length): word = t[0] if len(word) > 0 and word[0] in string.ascii_letters: lst.append(t) return sort_in_descending_order(lst) - + if __name__ == '__main__': - f = WordFreq('BANANA; Banana, apple ORANGE Banana banana.') + f = WordFreq('BANANA; Banana, apple ORANGE Banana banana.', max_word_length=30) print(f.get_freq()) - diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html old mode 100644 new mode 100755 index 8c684b6..57461c1 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -86,7 +86,7 @@

{{ today_article['source'] }}


- +

{{ today_article['question'] }}