<jupyter_start><jupyter_text>Reducer NER Class<jupyter_code>def reduce_ner_class(candidates_preds):

    if not isinstance(candidates_preds, zip):
        raise Exception("Tipo de estrutura não é aceita!")
     
    def __majority(candidate_tags): 
        try:
            return mode(candidate_tags)
        except StatisticsError:
            return 'O'

    return [__majority(tags) for tags in candidates_preds]
%%time

final_data_annotate = pd.DataFrame()

for index, text in enumerate(tqdm.notebook.tqdm(data.text[:100])):
    
    preproc_text = simple_clean_text(text)
    
    # Predictions #1
    stanza_pd = stanza_annotator(index,
                                 preproc_text,
                                 nlp_stanza_model)
    # Predictions #2
    spacy_pd = spacy_annotator(index,
                               preproc_text,
                               nlp_spacy_model)
    # Predictions #3
    spacy_pd_lg = spacy_annotator(index,
                                  preproc_text,
                                  nlp_spacy_model_lg)
    
    # Majority Vote or Mode
    stanza_pd.Tag = reduce_ner_class(zip(stanza_pd.Tag,
                                         spacy_pd.Tag,
                                         spacy_pd_lg.Tag))
    
    if len(stanza_pd.Tag.value_counts()) == 1:
        pass
    else:
        # Append on Final Model
        final_data_annotate = final_data_annotate.append(stanza_pd)
final_data_annotate
final_data_annotate.to_excel('data/final_data.csv', index=None)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07295029051000645, 'fraction_numerical': 0.004519044544867657, 'mean_word_length': 1.849264705882353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '151123', 'license': 'MIT', 'n_tokens_mistral': 490, 'n_tokens_neox': 474, 'n_words': 80, 'path': 'NER.Reducer.Annotator.ipynb', 'repo_name': 'mpgxc/NER.LabelingData', 'size': '1549'}