Handle BEL terms (the subject and object of BEL relations).
510291
def handle_term(self, _, __, tokens: ParseResults) -> ParseResults:
        """"""
        self.ensure_node(tokens)
        return tokens
1123168
def p_term_bool(self, p):
        '''  
        '''
        _LOGGER.debug("term -> TRUE/FALSE")

        if p[1].lower() == 'true':
            p[0] = TypedClass(True, TypedClass.BOOLEAN)
        else:
            p[0] = TypedClass(False, TypedClass.BOOLEAN)
1222403
private void relation(Options opt, RelationType rt, ClassDoc from,
	    ClassDoc to, String tailLabel, String label, String headLabel) {
	relation(opt, rt, from, from.toString(), to, to.toString(), tailLabel, label, headLabel);
    }
167605
def check_relations(self, relations):
        """"""
        for rel in relations:
            if not rel:
                continue
            fields = rel.split('.', 1)

            local_field = fields[0]
            if local_field not in self.fields:
                raise ValueError('Unknown field "{}"'.format(local_field))

            field = self.fields[local_field]
            if not isinstance(field, BaseRelationship):
                raise ValueError('Can only include relationships. "{}" is a "{}"'
                                 .format(field.name, field.__class__.__name__))

            field.include_data = True
            if len(fields) > 1:
                field.schema.check_relations(fields[1:])
1125648
def resolve(self, definitions):
        
        if not self.__resolved:
            self.do_resolve(definitions)
            self.__resolved = True
782991
def normalize_UNTL(subject):
    """"""
    subject = subject.strip()
    subject = re.sub(r'[\s]+', ' ', subject)
    return subject
738861
def as_bel(self) -> str:
        """"""
        return '{reference}.{start}_{stop}'.format(
            reference=self[FUSION_REFERENCE],
            start=self[FUSION_START],
            stop=self[FUSION_STOP],
        )
615514
def transform_relations(rdf, relationmap):
    """"""

    affected_types = (SKOS.Concept, SKOS.Collection,
                      SKOSEXT.DeprecatedConcept)

    props = set()
    for t in affected_types:
        for conc in rdf.subjects(RDF.type, t):
            for p, o in rdf.predicate_objects(conc):
                if isinstance(o, (URIRef, BNode)) \
                   and (p in relationmap or not in_general_ns(p)):
                    props.add(p)

    for p in props:
        if mapping_match(p, relationmap):
            newval = mapping_get(p, relationmap)
            logging.debug("transform relation %s -> %s", p, str(newval))
            replace_predicate(
                rdf, p, newval, subjecttypes=affected_types)
        else:
            logging.info("Don't know what to do with relation %s", p)
100055
def _verbs_with_subjects(doc):
    """"""
    # TODO: UNUSED
    verb_subj = []
    for possible_subject in doc:
        if (possible_subject.dep_ == 'nsubj' and possible_subject.head.pos_ ==
                'VERB'):
            verb_subj.append([possible_subject.head, possible_subject])
    return verb_subj
1352524
def _parse_with_relations(self, relations):
        
        results = {}

        for relation in relations:
            if isinstance(relation, dict):
                for name, constraints in relation.items():
                    results = self._parse_nested_with(name, results)

                    results[name] = constraints

                continue
            else:
                name = relation
                constraints = self.__class__(self.get_query().new_query())

            results = self._parse_nested_with(name, results)

            results[name] = constraints

        return results
220142
def match_relations(self, el, relation):
        """"""

        found = False

        if relation[0].rel_type.startswith(':'):
            found = self.match_future_relations(el, relation)
        else:
            found = self.match_past_relations(el, relation)

        return found
101800
def collect_consequences(self):
        
        consequences = {self.key()}
        for relation in self.referenced_by.values():
            consequences.update(relation.collect_consequences())
        return consequences
716070
def _nested_relations(self, relation):
        
        nested = {}

        for name, constraints in self._eager_load.items():
            if self._is_nested(name, relation):
                nested[name[len(relation + ".") :]] = constraints

        return nested
471148
def index(self):
        
        self.subjects = list(self.association_map.keys())

        # ensure annotations unique
        for (subj,terms) in self.association_map.items():
            self.association_map[subj] = list(set(self.association_map[subj]))
            
        logging.info("Indexing {} items".format(len(self.subjects)))
        n = 0
        all_objs = set()
        for (subj,terms) in self.association_map.items():
            ancs = self.termset_ancestors(terms)
            all_objs.update(ancs)
            self.subject_to_inferred_map[subj] = ancs
            n = n+1
            if n<5:
                logging.info(" Indexed: {} -> {}".format(subj, ancs))
            elif n == 6:
                logging.info("[TRUNCATING>5]....")
        self.objects = all_objs
247191
def relation_call(method, relation_name=None, flag=None, state=None, *args):
    """"""
    if relation_name:
        relation = relation_from_name(relation_name)
        if relation is None:
            raise ValueError('Relation not found: %s' % relation_name)
    elif flag or state:
        relation = relation_from_flag(flag or state)
        if relation is None:
            raise ValueError('Relation not found: %s' % (flag or state))
    else:
        raise ValueError('Must specify either relation_name or flag')
    result = getattr(relation, method)(*args)
    if isinstance(relation, RelationBase) and method == 'conversations':
        # special case for conversations to make them work from CLI
        result = [c.scope for c in result]
    return result
374823
def set_subject(self, value: Union[Literal, Identifier, str], lang: str= None):
        
        return self.metadata.add(key=DC.subject, value=value, lang=lang)
1202652
def extract_terms(self, nb):
        """"""
        emt = ExtractMetatabTerms()
        emt.preprocess(nb, {})

        return emt.terms