

@classmethod
def create(cls, **kwargs):

    def eo_args(tokens, eotokens, kind):
        txt = ' '.join(eotokens)
        return {
            'entity__key': txt,
            'entity__kind__name': kind,
            'alias': txt,
            'offset': len(tokens),
            'offset_end': (len(tokens) + len(eotokens)),
        }
    args = {
        
    }
    markup = kwargs.pop('markup', None)
    if (markup is not None):
        tokens = []
        e_occurrences = []
        while kwargs:
            if markup.startswith('{'):
                closer = markup.index('}')
                entity = markup[1:closer]
                markup = markup[(closer + 1):].lstrip()
                (eotokens, eokind) = entity.split('|')
                eotokens = eotokens.split()
                eo_flags = eokind.count('*')
                eokind = eokind.strip('*')
                eo_args_ = eo_args(tokens, eotokens, eokind)
                if (eo_flags == 2):
                    args.update({('left_entity_occurrence__%s' % k): v for (k, v) in eo_args_.items()})
                elif (eo_flags == 1):
                    args.update({('right_entity_occurrence__%s' % k): v for (k, v) in eo_args_.items()})
                else:
                    e_occurrences.append((eotokens, len(tokens), eokind))
                tokens += eotokens
            elif (' ' in markup):
                (token, markup) = markup.split(' ', 1)
                tokens.append(token)
            else:
                tokens.append(markup)
                markup = ''
        args['segment__document__text'] = ' '.join(tokens)
        args['segment__document__tokens'] = tokens
        args['segment__offset'] = 0
        args['segment__offset_end'] = len(tokens)
        args['e_occurrences'] = e_occurrences
        if ('syntactic_sentence' in kwargs):
            syntactic_sentence = kwargs.pop('syntactic_sentence')
            if isinstance(syntactic_sentence, str):
                syntactic_sentence = nltk.tree.Tree.fromstring(syntactic_sentence)
            args['segment__document__sentences'] = [0]
            args['segment__document__syntactic_sentences'] = [syntactic_sentence]
    args.update(kwargs)
    return super(EvidenceFactory, cls).create(**args)

dataset/ETHPy150Open machinalis/iepy/tests/factories.py EvidenceFactory.create/VarMisuse@121/153 `markup`->`kwargs`