コード例 #1
0
    def process_doc(self, doc: Document) -> Document:
        new_entities = []

        for ent in doc.entities:
            if ent.type in self.__filter:
                continue

            new_entities.append(ent.with_type(self.__replacements.get(ent.type, ent.type)))

        return doc.without_relations().without_entities().with_entities(new_entities)
コード例 #2
0
    def process_doc(self, doc: Document) -> Document:
        new_entities = []
        nes = []

        for ent in doc.entities:
            if ent.type in self.__filter:
                continue

            new_ne_type = self.__ne_replacements.get(ent.type, ent.type)
            new_ent_type = self.__ents_replacements.get(ent.type, ent.type)

            new_entities.append(ent.with_type(new_ent_type))
            nes.append(ent.with_type(new_ne_type))

        return doc.without_relations().without_entities().with_entities(new_entities). \
            with_additional_extras({"ne": SortedSpansSet(nes)})