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 discoverQuantifiedObjects(object):

    count_number = utilities.countNumber(False,object)
    reference = languageTools.trackReference(object)

    print(Cyn+"Building concept to search KB for"+st,object.lemma_, "'"+reference.lemma_+"'")

    features = languageTools.extractFeatures(object)
    facts = [["inst","?x",reference.lemma_]]
    for f in features:
        type = kb.whatAmI(f.lemma_)
        facts.append([type,"?x",f.lemma_])
    print(rd+"Looking for an ?x that matches:"+st)
    for f in facts:
        print("     ",f)
    bindings=kb.betterAsk(facts)
    if len(bindings) < count_number:
        print(Cyn+"We have a problem with too few objects matching in the KB"+st)
    elif bindings == False:
        print(Cyn+"We have a problem because nothing matches these facts in the KB"+st)
    else:
        print(Cyn+"Found references in KB:")
        print(Cyn+"Selecting a subset from",len(bindings),"elements")
        candidates = [a for a in map(lambda x: x["?x"], bindings)]
        print(longTermMemory)
        remaining = longTermMemory.getElementAndStatus(reference.lemma_, "remaining")
        if remaining:
            candidates = [a for a in filter(lambda x: x in remaining, candidates)]
            print(Cyn+"Filtering off of last statement")
        names = candidates[0:count_number]
        others = candidates[count_number:]
        print(Cyn+"Selected"+st, names)
        recentMemory.addElements(reference.lemma_, names)
        recentMemory.addElementAndStatus(reference.lemma_, others, "remaining")
        return names
def discoverQuantifiedObjects(object):

    count_number = utilities.countNumber(False,object)
    reference = languageTools.trackReference(object)

    print(Cyn+"Building concept to search KB for"+st,object.lemma_, "'"+reference.lemma_+"'")

    features = languageTools.extractFeatures(object)
    facts = [["inst","?x",reference.lemma_]]
    for f in features:
        type = kb.whatAmI(f.lemma_)
        facts.append([type,"?x",f.lemma_])
    print(rd+"Looking for an ?x that matches:"+st)
    for f in facts:
        print("     ",f)
    bindings=kb.betterAsk(facts)
    if len(bindings) < count_number:
        print(Cyn+"We have a problem with too few objects matching in the KB"+st)
    elif bindings == False:
        print(Cyn+"We have a problem because nothing matches these facts in the KB"+st)
    else:
        print(Cyn+"Found references in KB:")
        print(Cyn+"Selecting a subset from",len(bindings),"elements")
        candidates = [a for a in map(lambda x: x["?x"], bindings)]
        print(longTermMemory)
        remaining = longTermMemory.getElementAndStatus(reference.lemma_, "remaining")
        if remaining:
            candidates = [a for a in filter(lambda x: x in remaining, candidates)]
            print(Cyn+"Filtering off of last statement")
        names = candidates[0:count_number]
        others = candidates[count_number:]
        print(Cyn+"Selected"+st, names)
        recentMemory.addElements(reference.lemma_, names)
        recentMemory.addElementAndStatus(reference.lemma_, others, "remaining")
        return names