def buildNewObject(object): print(Blu + "Referenced object is being defined in sentence" + st) print(Blu + "Building new object:" + st, object.lemma_) # Is this a statement about a single object or a set of objects # to do this to need to get the deteminer and the count we are only considering between # between 1 and 10. We also have a utility that converts names to numbers. determiner = languageTools.extractDeterminer(object) count = languageTools.extractCount(object) count_number = utilities.countNumber(determiner, count) print(Blu + "Count:" + st, str(count_number)) # We generate new names for each of our new objects names = utilities.genNames(object.lemma_, count_number) print(Blu + "New Names:" + st, names) # Now we can begin making statements about our objects, first, we need to Assert that they exist buildAndAssertObjectStatementFOPC(object, names) # Next we pull out any features associated with the object and attach then to the object findAndAssertFeaturesFOPC(object, names) # And build up statement about any prepositional phrases linked to the object findAndAttachPrepObjectsFOPC(object, object, names) print(Blu + "Done building:" + st, object.lemma_) recentMemory.addElements(object.lemma_, names) return names
def buildNewObject(object): print(Blu+"Referenced object is being defined in sentence"+st) print(Blu+"Building new object:"+st, object.lemma_) # Is this a statement about a single object or a set of objects # to do this to need to get the deteminer and the count we are only considering between # between 1 and 10. We also have a utility that converts names to numbers. determiner = languageTools.extractDeterminer(object) count = languageTools.extractCount(object) count_number = utilities.countNumber(determiner,count) print(Blu+"Count:"+st, str(count_number)) # We generate new names for each of our new objects names = utilities.genNames(object.lemma_,count_number) print(Blu+"New Names:"+st, names) # Now we can begin making statements about our objects, first, we need to Assert that they exist buildAndAssertObjectStatementFOPC(object, names) # Next we pull out any features associated with the object and attach then to the object findAndAssertFeaturesFOPC(object,names) # And build up statement about any prepositional phrases linked to the object findAndAttachPrepObjectsFOPC(object,object,names) print(Blu+"Done building:"+st, object.lemma_) recentMemory.addElements(object.lemma_,names) return names
def resolveObjectFOPC(object): global recentMemory # First, we want to find out if the object is the name for anything we know about # To do this, we need to find out if it is a proper noun and if it exists in the KB. # If it does, then we are just going to return its name. print(lf + Grn + "Resolving object:" + st, object.lemma_) if object.pos_ == "PROPN": print(object.text, Grn + " is a proper name." + st) inst = kb.betterAsk(["inst", object.text, "?x"]) recentMemory.addElements(inst, [object.text]) print(Grn + "Returning" + st, object.text) return [object.text] # The object might also be a referent that quantifies something else. When we identify that we # then have to go find it. if object.pos_ == "ADJ": objects = discoverReferencedObjects(object) print(Grn + "Returning" + st, objects) return objects # Next we need to do is find out the determiner. If it is 'the', we are referring # an existing object and need to look it up. determiner = languageTools.extractDeterminer(object) if determiner != None: if determiner.lemma_ == "the": new_obj = discoverObject(object) print(Grn + "Returning" + st, new_obj) return new_obj # The object might also be a referent that quantifies something else. When we identify that we # then have to go find it. if object.pos_ == "NUM": new_objs = discoverQuantifiedObjects(object) print(Grn + "Returning" + st, new_objs) return new_objs # If it is neither an existing object in the KB nor the name of a thing, then it is something # we have to build and assert new_objs = buildNewObject(object) print(Grn + "Returning" + st, new_objs) return new_objs
def resolveObjectFOPC(object): global recentMemory # First, we want to find out if the object is the name for anything we know about # To do this, we need to find out if it is a proper noun and if it exists in the KB. # If it does, then we are just going to return its name. print(lf+Grn+"Resolving object:"+st, object.lemma_) if object.pos_ == "PROPN": print(object.text, Grn+" is a proper name."+st) inst = kb.betterAsk(["inst", object.text,"?x"]) recentMemory.addElements(inst,[object.text]) print(Grn+"Returning"+st, object.text) return [object.text] # The object might also be a referent that quantifies something else. When we identify that we # then have to go find it. if object.pos_ == "ADJ": objects = discoverReferencedObjects(object) print(Grn+"Returning"+st, objects) return objects # Next we need to do is find out the determiner. If it is 'the', we are referring # an existing object and need to look it up. determiner = languageTools.extractDeterminer(object) if determiner != None: if determiner.lemma_ == "the": new_obj = discoverObject(object) print(Grn+"Returning"+st, new_obj) return new_obj # The object might also be a referent that quantifies something else. When we identify that we # then have to go find it. if object.pos_ == "NUM": new_objs = discoverQuantifiedObjects(object) print(Grn+"Returning"+st, new_objs) return new_objs # If it is neither an existing object in the KB nor the name of a thing, then it is something # we have to build and assert new_objs = buildNewObject(object) print(Grn+"Returning"+st, new_objs) return new_objs