Beispiel #1
0
def bottom_up_correspondence_scout(codelet):
    objectFromInitial = chooseUnmodifiedObject('interStringSalience',
                                               workspace.initial.objects)
    objectFromTarget = chooseUnmodifiedObject('interStringSalience',
                                              workspace.target.objects)
    assert objectFromInitial.spansString() == objectFromTarget.spansString()
    # get the posible concept mappings
    conceptMappings = formulas.getMappings(
        objectFromInitial, objectFromTarget,
        objectFromInitial.relevantDescriptions(),
        objectFromTarget.relevantDescriptions())
    assert conceptMappings and __slippability(conceptMappings)
    #find out if any are distinguishing
    distinguishingMappings = [m for m in conceptMappings if m.distinguishing()]
    assert distinguishingMappings
    # if both objects span the strings, check to see if the
    # string description needs to be flipped
    opposites = [m for m in distinguishingMappings
                 if m.initialDescriptionType == slipnet.stringPositionCategory
                 and m.initialDescriptionType != slipnet.bondFacet]
    initialDescriptionTypes = [m.initialDescriptionType for m in opposites]
    flipTargetObject = False
    if  (objectFromInitial.spansString() and
         objectFromTarget.spansString() and
         slipnet.directionCategory in initialDescriptionTypes
         and __allOppositeMappings(formulas.oppositeMappings)
         and slipnet.opposite.activation != 100.0):
        objectFromTarget = objectFromTarget.flippedVersion()
        conceptMappings = formulas.getMappings(
            objectFromInitial, objectFromTarget,
            objectFromInitial.relevantDescriptions(),
            objectFromTarget.relevantDescriptions())
        flipTargetObject = True
    coderack.proposeCorrespondence(objectFromInitial, objectFromTarget,
                                   conceptMappings, flipTargetObject, codelet)
Beispiel #2
0
def important_object_correspondence_scout(codelet):
    objectFromInitial = chooseUnmodifiedObject('relativeImportance',
                                               workspace.initial.objects)
    descriptors = objectFromInitial.relevantDistinguishingDescriptors()
    slipnode = formulas.chooseSlipnodeByConceptualDepth(descriptors)
    assert slipnode
    initialDescriptor = slipnode
    for mapping in workspace.slippages():
        if mapping.initialDescriptor == slipnode:
            initialDescriptor = mapping.targetDescriptor
    targetCandidates = []
    for objekt in workspace.target.objects:
        for description in objekt.relevantDescriptions():
            if description.descriptor == initialDescriptor:
                targetCandidates += [objekt]
    assert targetCandidates
    objectFromTarget = chooseUnmodifiedObject('interStringSalience',
                                              targetCandidates)
    assert objectFromInitial.spansString() == objectFromTarget.spansString()
    # get the posible concept mappings
    conceptMappings = formulas.getMappings(
        objectFromInitial, objectFromTarget,
        objectFromInitial.relevantDescriptions(),
        objectFromTarget.relevantDescriptions())
    assert conceptMappings
    assert __slippability(conceptMappings)
    # find out if any are distinguishing
    distinguishingMappings = [m for m in conceptMappings if m.distinguishing()]
    assert distinguishingMappings
    # if both objects span the strings, check to see if the
    # string description needs to be flipped
    opposites = [
        m for m in distinguishingMappings
        if m.initialDescriptionType == slipnet.stringPositionCategory and
        m.initialDescriptionType != slipnet.bondFacet]
    initialDescriptionTypes = [m.initialDescriptionType for m in opposites]
    flipTargetObject = False
    if (objectFromInitial.spansString() and
            objectFromTarget.spansString() and
            slipnet.directionCategory in initialDescriptionTypes and
            __allOppositeMappings(formulas.oppositeMappings) and
            slipnet.opposite.activation != 100.0):
        objectFromTarget = objectFromTarget.flippedVersion()
        conceptMappings = formulas.getMappings(
            objectFromInitial, objectFromTarget,
            objectFromInitial.relevantDescriptions(),
            objectFromTarget.relevantDescriptions())
        flipTargetObject = True
    coderack.proposeCorrespondence(objectFromInitial, objectFromTarget,
                                   conceptMappings, flipTargetObject, codelet)
Beispiel #3
0
def top_down_description_scout(codelet):
    descriptionType = codelet.arguments[0]
    chosenObject = chooseUnmodifiedObject('totalSalience', workspace.objects)
    assert chosenObject
    __showWhichStringObjectIsFrom(chosenObject)
    descriptions = chosenObject.getPossibleDescriptions(descriptionType)
    assert descriptions
    values = [n.activation for n in descriptions]
    i = formulas.selectListPosition(values)
    chosenProperty = descriptions[i]
    coderack.proposeDescription(chosenObject, chosenProperty.category(),
                                chosenProperty, codelet)
Beispiel #4
0
def bottom_up_correspondence_scout(codelet):
    objectFromInitial = chooseUnmodifiedObject('interStringSalience',
                                               workspace.initial.objects)
    objectFromTarget = chooseUnmodifiedObject('interStringSalience',
                                              workspace.target.objects)
    assert objectFromInitial.spansString() == objectFromTarget.spansString()
    # get the posible concept mappings
    conceptMappings = formulas.getMappings(
        objectFromInitial, objectFromTarget,
        objectFromInitial.relevantDescriptions(),
        objectFromTarget.relevantDescriptions())
    assert conceptMappings
    assert __slippability(conceptMappings)
    # find out if any are distinguishing
    distinguishingMappings = [m for m in conceptMappings if m.distinguishing()]
    assert distinguishingMappings
    # if both objects span the strings, check to see if the
    # string description needs to be flipped
    opposites = [
        m for m in distinguishingMappings
        if m.initialDescriptionType == slipnet.stringPositionCategory and
        m.initialDescriptionType != slipnet.bondFacet]
    initialDescriptionTypes = [m.initialDescriptionType for m in opposites]
    flipTargetObject = False
    if (objectFromInitial.spansString() and
            objectFromTarget.spansString() and
            slipnet.directionCategory in initialDescriptionTypes and
            __allOppositeMappings(formulas.oppositeMappings) and
            slipnet.opposite.activation != 100.0):
        objectFromTarget = objectFromTarget.flippedVersion()
        conceptMappings = formulas.getMappings(
            objectFromInitial, objectFromTarget,
            objectFromInitial.relevantDescriptions(),
            objectFromTarget.relevantDescriptions())
        flipTargetObject = True
    coderack.proposeCorrespondence(objectFromInitial, objectFromTarget,
                                   conceptMappings, flipTargetObject, codelet)
Beispiel #5
0
def bottom_up_description_scout(codelet):
    chosenObject = chooseUnmodifiedObject('totalSalience', workspace.objects)
    assert chosenObject
    __showWhichStringObjectIsFrom(chosenObject)
    description = formulas.chooseRelevantDescriptionByActivation(chosenObject)
    assert description
    sliplinks = formulas.similarPropertyLinks(description.descriptor)
    assert sliplinks
    values = [sliplink.degreeOfAssociation() * sliplink.destination.activation
              for sliplink in sliplinks]
    i = formulas.selectListPosition(values)
    chosen = sliplinks[i]
    chosenProperty = chosen.destination
    coderack.proposeDescription(chosenObject, chosenProperty.category(),
                                chosenProperty, codelet)
Beispiel #6
0
def bottom_up_bond_scout(codelet):
    source = chooseUnmodifiedObject('intraStringSalience', workspace.objects)
    __showWhichStringObjectIsFrom(source)
    destination = chooseNeighbour(source)
    assert destination
    logging.info('destination: %s', destination)
    bondFacet = __getBondFacet(source, destination)
    logging.info('chosen bond facet: %s', bondFacet.get_name())
    logging.info('Source: %s, destination: %s', source, destination)
    bond_descriptors = __getDescriptors(bondFacet, source, destination)
    sourceDescriptor, destinationDescriptor = bond_descriptors
    logging.info("source descriptor: %s", sourceDescriptor.name.upper())
    logging.info("destination descriptor: %s",
                 destinationDescriptor.name.upper())
    category = sourceDescriptor.getBondCategory(destinationDescriptor)
    assert category
    if category == slipnet.identity:
        category = slipnet.sameness
    logging.info('proposing %s bond ', category.name)
    coderack.proposeBond(source, destination, category, bondFacet,
                         sourceDescriptor, destinationDescriptor, codelet)
Beispiel #7
0
def __getScoutSource(slipnode, relevanceMethod, typeName):
    initialRelevance = relevanceMethod(workspace.initial, slipnode)
    targetRelevance = relevanceMethod(workspace.target, slipnode)
    initialUnhappiness = workspace.initial.intraStringUnhappiness
    targetUnhappiness = workspace.target.intraStringUnhappiness
    logging.info('initial : relevance = %d, unhappiness=%d',
                 initialRelevance, int(initialUnhappiness))
    logging.info('target : relevance = %d, unhappiness=%d',
                 targetRelevance, int(targetUnhappiness))
    string = workspace.initial
    relevances = initialRelevance + targetRelevance
    unhappinesses = initialUnhappiness + targetUnhappiness
    randomized = random.random() * (relevances + unhappinesses)
    initials = initialRelevance + initialUnhappiness
    if randomized > initials:
        string = workspace.target
        logging.info('target string selected: %s for %s',
                     workspace.target, typeName)
    else:
        logging.info('initial string selected: %s for %s',
                     workspace.initial, typeName)
    source = chooseUnmodifiedObject('intraStringSalience', string.objects)
    return source