Пример #1
0
    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))
Пример #2
0
    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
 def test_esta_en_google_consulta_palabra_comun(self):
     texto = "hola"
     self.assertTrue(Google.esta_en_google_consulta(texto), "Debería estar en google el texto \"" + texto + "\"")
Пример #4
0
 def test_esta_en_google_palabra_inexistente2(self):
     texto = "aldnkvnvrbyweruvnrhuvhuirbv"
     self.assertFalse(Google.esta_en_google(texto),
                      "No debería estar el diccionario de en google el texto \"" + texto + "\"")
Пример #5
0
 def test_esta_en_google_palabra_inexistente(self):
     texto = "jajajajaaaaaaaa"
     self.assertFalse(Google.esta_en_google(texto),
                      "No debería estar el diccionario de en google el texto \"" + texto + "\"")
Пример #6
0
 def test_esta_en_google_error_de_tipeo(self):
     texto = "holaa"
     self.assertFalse(Google.esta_en_google(texto),
                      "No debería estar el diccionario de en google el texto \"" + texto + "\"")
Пример #7
0
 def test_esta_en_google_palabra_comun_con_acento(self):
     texto = "árbol"
     self.assertTrue(Google.esta_en_google(texto),
                     "Debería estar en el diccionario de google el texto \"" + texto + "\"")
Пример #8
0
 def test_esta_en_google_consulta_palabra_inexistente(self):
     texto = "jajajajaaaaaaaa"
     self.assertFalse(Google.esta_en_google_consulta(texto), "No debería estar en google el texto \"" + texto + "\"")
Пример #9
0
 def test_esta_en_google_consulta_error_de_tipeo(self):
     texto = "trvaesuras"  # "holaa" comenzó a estar en google
     self.assertFalse(Google.esta_en_google_consulta(texto), "No debería estar en google el texto \"" + texto + "\"")
Пример #10
0
 def test_esta_en_google_consulta_palabra_comun(self):
     texto = "hola"
     self.assertTrue(Google.esta_en_google_consulta(texto),
                     "Debería estar en google el texto \"" + texto + "\"")
Пример #11
0
 def test_esta_en_google_palabra_inexistente2(self):
     texto = "aldnkvnvrbyweruvnrhuvhuirbv"
     self.assertFalse(
         Google.esta_en_google(texto),
         "No debería estar el diccionario de en google el texto \"" +
         texto + "\"")
Пример #12
0
 def test_esta_en_google_palabra_inexistente(self):
     texto = "jajajajaaaaaaaa"
     self.assertFalse(
         Google.esta_en_google(texto),
         "No debería estar el diccionario de en google el texto \"" +
         texto + "\"")
Пример #13
0
 def test_esta_en_google_error_de_tipeo(self):
     texto = "holaa"
     self.assertFalse(
         Google.esta_en_google(texto),
         "No debería estar el diccionario de en google el texto \"" +
         texto + "\"")
Пример #14
0
 def test_esta_en_google_palabra_comun_con_acento(self):
     texto = "árbol"
     self.assertTrue(
         Google.esta_en_google(texto),
         "Debería estar en el diccionario de google el texto \"" + texto +
         "\"")
Пример #15
0
 def test_esta_en_google_consulta_palabra_inexistente(self):
     texto = "jajajajaaaaaaaa"
     self.assertFalse(
         Google.esta_en_google_consulta(texto),
         "No debería estar en google el texto \"" + texto + "\"")
Пример #16
0
 def test_esta_en_google_consulta_error_de_tipeo(self):
     texto = "trvaesuras"  # "holaa" comenzó a estar en google
     self.assertFalse(
         Google.esta_en_google_consulta(texto),
         "No debería estar en google el texto \"" + texto + "\"")