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 Wiktionary.pertenece(token): cant_palabras_oov += 1 if len(tokens) == 0: return 0 else: return cant_palabras_oov / math.sqrt(len(tokens))
def test_esta_en_wiktionary_consulta_palabra_comun(self): texto = "hola" self.assertTrue(Wiktionary.pertenece_consulta(texto), "Debería estar en wiktionary el texto \"" + texto + "\"")
def test_esta_en_wiktionary_palabra_cotidiana(self): texto = "Suárez" self.assertTrue(Wiktionary.pertenece(texto), "Debería estar en wiktionary el texto \"" + texto + "\"")
def test_esta_en_wiktionary_palabra_inexistente2(self): texto = "aldnkvnvrbyweruvnrhuvhuirbv" self.assertFalse(Wiktionary.pertenece(texto), "No debería estar el diccionario de en wiktionary el texto \"" + texto + "\"")
def test_esta_en_wiktionary_palabra_inexistente(self): texto = "jajajajaaaaaaaa" self.assertFalse(Wiktionary.pertenece(texto), "No debería estar el diccionario de en wiktionary el texto \"" + texto + "\"")
def test_esta_en_wiktionary_error_de_tipeo(self): texto = "holaa" self.assertFalse(Wiktionary.pertenece(texto), "No debería estar el diccionario de en wiktionary el texto \"" + texto + "\"")
def test_esta_en_wiktionary_palabra_comun_con_acento(self): texto = "árbol" self.assertTrue(Wiktionary.pertenece(texto), "Debería estar en el diccionario de wiktionary el texto \"" + texto + "\"")