entities.py 1.18 KB
from corneferencer.resolvers.vectors import get_mention_features


class Text:

    def __init__(self, text_id):
        self.__id = text_id
        self.mentions = []

    def get_mention_set(self, mnt_id):
        for mnt in self.mentions:
            if mnt.id == mnt_id:
                return mnt.set
        return None


class Mention:

    def __init__(self, mnt_id, text, lemmatized_text, words, span,
                 head_orth, head_base, dominant, node, prec_context,
                 follow_context, sentence, position_in_mentions,
                 start_in_words, end_in_words):
        self.id = mnt_id
        self.set = ''
        self.text = text
        self.lemmatized_text = lemmatized_text
        self.words = words
        self.span = span
        self.head_orth = head_orth
        self.head_base = head_base
        self.dominant = dominant
        self.node = node
        self.prec_context = prec_context
        self.follow_context = follow_context
        self.sentence = sentence
        self.position_in_mentions = position_in_mentions
        self.start_in_words = start_in_words
        self.end_in_words = end_in_words
        self.features = get_mention_features(self)