def align_entity_types(self, sample: InputSample) -> None: """ Translates the sample's tags to the ones requested by the model :param sample: Input sample :return: None """ if self.entity_mapping: sample.translate_input_sample_tags(dictionary=self.entity_mapping)
def predict(self, sample: InputSample) -> List[str]: if self.translate_to_spacy_entities: sample.translate_input_sample_tags() doc = self.model(sample.full_text) tags = self.get_tags_from_doc(doc) if len(doc) != len(sample.tokens): print("mismatch between input tokens and new tokens") return tags
def predict(self, sample: InputSample) -> List[str]: if self.translate_to_spacy_entities: sample.translate_input_sample_tags() sentence = Sentence(text=sample.full_text, use_tokenizer=self.spacy_tokenizer) self.model.predict(sentence) tags = self.get_tags_from_sentence(sentence) if len(tags) != len(sample.tokens): print("mismatch between previous tokens and new tokens") return tags