def decode_adjective(self, deep_ref, from_xx, to_xx): adj = deep_ref.arg.s noun = Noun(attributes=[adj]) x = self.add_idea(noun) return [[x]]
def decode_common_noun(self, deep_ref, from_xx, to_xx): n = deep_ref.arg assert not n.possessor if n.number and n.number.is_interrogative() and not n.rels_nargs: assert n.selector.correlative == Correlative.INDEF idea = Noun(query=Query.CARDINALITY, attributes=n.attributes, kind=n.noun) x = self.add_idea(idea) return [[x]] if n.selector.correlative == Correlative.INDEF and not n.rels_nargs: if n.selector.n_min == N5.SING and n.selector.n_max == N5.SING: # Create a new one. idea = Noun(attributes=n.attributes, kind=n.noun) x = self.add_idea(idea) return [[x]] elif N5.DUAL <= n.selector.n_min: # It's referring to all of instances with those fields. features = NounFeatures(query=Query.GENERIC, attributes=n.attributes, kind=n.noun) xx = self.resolve_one_noun(features) return [xx] else: assert False assert n.selector.correlative in [ Correlative.DEF, Correlative.DIST, Correlative.INTR, ] if n.selector.correlative == Correlative.INTR: idea = Noun(query=Query.IDENTITY, attributes=n.attributes, kind=n.noun) x = self.add_idea(idea) return [[x]] d = n.selector.dump() del d['correlative'] if d != { 'n_min': 'SING', 'n_max': 'SING', 'of_n_min': 'SING', 'of_n_max': 'SING', }: pass # TODO: actually handle this correctly. rel2xxx = {} for rel, narg in n.rels_nargs: sub_ref = DeepReference(owning_clause_id=deep_ref.owning_clause_id, is_subj=False, arg=narg) xxx = self.decode(sub_ref, from_xx, to_xx) rel2xxx[rel] = xxx if n.noun == 'person': gender = None else: gender = Gender.NEUTER features = NounFeatures(attributes=n.attributes, kind=n.noun, gender=gender, rel2xxx=rel2xxx) xx = self.resolve_one_noun(features) return [xx]
def new(self): uid = randint(0, 0x7FFFFFFFFFFFFFFF) assert uid not in self.uid2x x = self.memory.add_idea(Noun(kind='person')) self.uid2x[uid] = x return uid