예제 #1
0
    def get_least_freq(self, x=None):
        """
        Returns the x least frequent words with their frequencies,
        or all words with their frequencies if x is not specified.
        :param x: the number of least frequent words to return
        """
        if self.__freq_dist is None:
            self.__freq_dist = Util.get_freq_dist(self.__tokens)

        most_common = self.__freq_dist.most_common()
        freq_dist = []
        count = 0
        for item in reversed(most_common):
            freq_dist.append(item)
        temp_freq = []

        if x is None:
            freq_dist = freq_dist
        else:
            for item in freq_dist:
                if count < int(x):
                    temp_freq.append(item)
                    count += 1

            freq_dist = temp_freq

        return freq_dist
예제 #2
0
파일: SPLAT.py 프로젝트: meyersbs/SPLAT
    def get_least_freq(self, x=None):
        """
        Returns the x least frequent words with their frequencies,
        or all words with their frequencies if x is not specified.
        :param x: the number of least frequent words to return
        """
        if self.__freq_dist is None:
            self.__freq_dist = Util.get_freq_dist(self.__tokens)

        most_common = self.__freq_dist.most_common()
        freq_dist = []
        count = 0
        for item in reversed(most_common):
                freq_dist.append(item)
        temp_freq = []

        if x is None:
            freq_dist = freq_dist
        else:
            for item in freq_dist:
                if count < int(x):
                    temp_freq.append(item)
                    count += 1

            freq_dist = temp_freq

        return freq_dist
예제 #3
0
 def plot_freq(self, x=None):
     """ Uses matplotlib to graph the frequency distribution.
     :param x:
     """
     if self.__freq_dist is None:
         self.__freq_dist = Util.get_freq_dist(self.__tokens)
     Util.plot_freq_dist(self.__freq_dist, x)
     return ''
예제 #4
0
파일: SPLAT.py 프로젝트: meyersbs/SPLAT
 def plot_freq(self, x=None):
     """ Uses matplotlib to graph the frequency distribution.
     :param x:
     """
     if self.__freq_dist is None:
         self.__freq_dist = Util.get_freq_dist(self.__tokens)
     Util.plot_freq_dist(self.__freq_dist, x)
     return ''
예제 #5
0
 def get_most_freq(self, x=None):
     """
     Returns the x most frequent words with their frequencies,
     or all words with their frequencies if x is not specified.
     :param x: the number of most frequent words to return
     """
     if self.__freq_dist is None:
         self.__freq_dist = Util.get_freq_dist(self.__tokens)
     if x is None:
         return self.__freq_dist.most_common()
     elif x > 0:
         return self.__freq_dist.most_common(x)
     else:
         return self.__freq_dist.most_common()
예제 #6
0
파일: SPLAT.py 프로젝트: meyersbs/SPLAT
 def get_most_freq(self, x=None):
     """
     Returns the x most frequent words with their frequencies,
     or all words with their frequencies if x is not specified.
     :param x: the number of most frequent words to return
     """
     if self.__freq_dist is None:
         self.__freq_dist = Util.get_freq_dist(self.__tokens)
     if x is None:
         return self.__freq_dist.most_common()
     elif x > 0:
         return self.__freq_dist.most_common(x)
     else:
         return self.__freq_dist.most_common()