コード例 #1
0
ファイル: oovfreeling.py プロジェクト: zni1/pghumor
    def calcular_feature(self, tweet):
        texto = tweet.texto
        texto = remover_hashtags(texto)
        texto = remover_usuarios(texto)
        oraciones = Freeling.procesar_texto(texto)
        tokens = list(itertools.chain(*oraciones))

        cant_palabras_oov = 0
        for token_freeling in tokens:
            if not token_freeling.tag.startswith('F') \
                    and not token_freeling.tag.startswith('Z') \
                    and not token_freeling.tag.startswith('W'):
                token = eliminar_underscores(token_freeling.token)
                if not Freeling.esta_en_diccionario(token):
                    cant_palabras_oov += 1

        if len(tokens) == 0:
            return 0
        else:
            return cant_palabras_oov / math.sqrt(len(tokens))
コード例 #2
0
ファイル: oov.py プロジェクト: bryant1410/pghumor
    def calcular_feature(self, tweet):
        texto = tweet.texto
        texto = remover_hashtags(texto)
        texto = remover_usuarios(texto)
        oraciones = Freeling.procesar_texto(texto)
        tokens = list(itertools.chain(*oraciones))

        cant_palabras_oov = 0
        for token_freeling in tokens:
            if not token_freeling.tag.startswith('F') \
                    and not token_freeling.tag.startswith('Z') \
                    and not token_freeling.tag.startswith('W'):
                token = eliminar_underscores(token_freeling.token)
                if not Freeling.esta_en_diccionario(token) and not Google.esta_en_google(token):
                    cant_palabras_oov += 1

        if len(tokens) == 0:
            return 0
        else:
            return cant_palabras_oov / math.sqrt(len(tokens))
コード例 #3
0
ファイル: testfreeling.py プロジェクト: bryant1410/pghumor
 def test_esta_en_diccionario_palabra_inexistente(self):
     texto = "wkalskjv"
     self.assertFalse(Freeling.esta_en_diccionario(texto),
                      "No debería estar en el diccionario el texto \"" + texto + "\"")
コード例 #4
0
ファイル: testfreeling.py プロジェクト: bryant1410/pghumor
 def test_esta_en_diccionario_palabra_comun(self):
     texto = "reja"
     self.assertTrue(Freeling.esta_en_diccionario(texto),
                     "Debería estar en el diccionario el texto \"" + texto + "\"")
コード例 #5
0
 def test_esta_en_diccionario_palabra_inexistente(self):
     texto = "wkalskjv"
     self.assertFalse(
         Freeling.esta_en_diccionario(texto),
         "No debería estar en el diccionario el texto \"" + texto + "\"")
コード例 #6
0
 def test_esta_en_diccionario_palabra_comun(self):
     texto = "reja"
     self.assertTrue(
         Freeling.esta_en_diccionario(texto),
         "Debería estar en el diccionario el texto \"" + texto + "\"")