def processar(self):
        strategyTF = tf_class.DoubleNormalization()
        # print('\nprocessar      ', strategyTF, '\n')
        self.tf = {}
        self.logNormalization = {}
        self.doubleNormalization = {}
        for word in self.tokens:
            # termo = Termo()
            frequency = self.tokens[word]

            self.tokens[word] = strategyTF.calcPeso(frequency, self)
            self.tf[word] = strategyTF.calcPeso(frequency, self)
            self.logNormalization[word] = tf_class.LogNormalization().calcPeso(
                frequency, self)
            self.doubleNormalization[word] = tf_class.DoubleNormalization(
            ).calcPeso(frequency, self)
Esempio n. 2
0
    def processar(self, colecao):
        strategyTF = self.instanciar(tf, colecao.algoritmo['tf'])
        # print('\t\tprocessar      ', strategyTF)
        # strategyIDF = self.instanciar(idf_class, strategyIDF)
        # strategyTFIDF = self.instanciar(tfidf_class, strategyTFIDF)
        # print(self.tokens)
        for word in self.tokens:
            # termo = Termo()
            frequency = self.tokens[word]
            # termo.tf = strategyTF.calcularPeso(termo, self)
            # termo.idf = idf = strategyIDF.calcularPeso(termo, listaDocumentos)
            # termo.tfIdf = termo.tf * termo.idf

            self.tf[word] = strategyTF.calcPeso(frequency, self)
            self.logNormalization[word] = tf.LogNormalization().calcPeso(
                frequency, self)
            self.doubleNormalization[word] = tf.DoubleNormalization().calcPeso(
                frequency, self)

            if (word in colecao.qtTermoDocumento):
                colecao.qtTermoDocumento[word] += 1
            else:
                colecao.qtTermoDocumento[word] = 1

            if not (word in colecao.listTermosColecao):
                colecao.listTermosColecao.append(word)