Example #1
0
def freq_dist_demostration():  # 1.8
    fdist1 = FreqDist(text1)
    pprint(fdist1.most_common(30))  # с помощью функции most_common мы определили 30 популярных слов
    pprint(fdist1.pformat(2))  # конвертирует это в строку
    fdist1.plot(50)  # Строит графики
Example #2
0
class Sentence:
    def __init__(self, wordList):
        self.wordFreqDict = FreqDist(wordList)#Dictionary of words in the sentence and corres. frequency
        self.assignedAspect = [] #list of aspects assigned to this sentence
    def __str__(self):
        return self.wordFreqDict.pformat(10000) + '##' + str(self.assignedAspect)