Esempio n. 1
0
 def make_term(self, name, term_type, **objs):
     '''
     Make a Term from a name (string) and a term_type (Term).
     Can also produce a predicate.
     The term is not saved or added to the session.
     '''
     try:
         return self.get_term(name)
     except exceptions.TermNotFound:
         if are(term_type, self.noun):
             return self._make_noun(name, ntype=term_type)
         elif are(term_type, self.thing):
             return self._make_name(name, term_type)
         elif are(term_type, self.verb):
             return self._make_verb(name, vtype=term_type, objs=objs)
         elif are(term_type, self.exist):
             return self.make_pred(name, term_type, **objs)
         elif term_type == self.number:
             return self.make_number(name)
         else:
             return Term(name, ttype=term_type)
Esempio n. 2
0
 def make_subterm(self, name, super_terms, **objs):
     '''
     Make a Term from a name (string) and bases (Term's).
     The bases are the supertypes of a type,
     and can be a tuple of terms or a single term.
     The term is not saved or added to the session.
     '''
     try:
         return self.get_term(name)
     except exceptions.TermNotFound:
         if isa(super_terms, self.word):
             super_terms = (super_terms,)
         term_base = super_terms[0]
         if are(term_base, self.noun):
             return self._make_subnoun(name, bases=super_terms)
         elif are(term_base, self.thing):
             return self._make_noun(name, bases=super_terms)
         elif are(term_base, self.verb):
             return self._make_subverb(name, bases=super_terms)
         elif are(term_base, self.exist):
             return self._make_verb(name, bases=super_terms, objs=objs)
Esempio n. 3
0
 def test(self, match, network):
     sub = self.args[0].solve(match)
     super_ = self.args[1].solve(match)
     logger.debug('matching: {!r} and {!r}'.format(sub, super_))
     return are(sub, super_)