<jupyter_start><jupyter_text><jupyter_code>!python -m spacy download es_core_news_sm
!pip install apex
import pandas as pd
import matplotlib.pyplot as plt
import spacy
import es_core_news_sm
nlp = es_core_news_sm.load()
import re
f = open('reporte_ejemplo.txt', 'r')
texto = f.read()
texto
doc = nlp(texto)
for token in doc:
  if 'X' in token.shape_:
    print(token.text, end=' * ')
from spacy import displacy
displacy.render(doc, style='ent', jupyter=True, options={'distance': 140})
frase = nlp('El herido fue auxiliado por sus compañeros y trasladado a un hospital.')
extractos = []
HORIZ_SIM = 0.4
for token1 in frase:
  for token2 in frase:
    sim = token1.similarity(token2)
    if sim > HORIZ_SIM and sim < 1:
      extractos.append([token1.text, token2.text, sim])
extractos<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.014492753623188406, 'mean_word_length': 4.526666666666666, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '366668', 'license': 'MIT', 'n_tokens_mistral': 326, 'n_tokens_neox': 316, 'n_words': 87, 'path': 'gdmk_lab__texto.ipynb', 'repo_name': 'jcmachicao/modpred_2', 'size': '828'}