Exemple #1
0
def top_down_bond_scout__category(codelet):
    logging.info('top_down_bond_scout__category')
    category = codelet.arguments[0]
    source = __getScoutSource(category, formulas.localBondCategoryRelevance,
                              'bond')
    destination = chooseNeighbour(source)
    logging.info('source: %s, destination: %s', source, destination)
    assert destination
    bondFacet = __getBondFacet(source, destination)
    sourceDescriptor, destinationDescriptor = __getDescriptors(
        bondFacet, source, destination)
    forwardBond = sourceDescriptor.getBondCategory(destinationDescriptor)
    if forwardBond == slipnet.identity:
        forwardBond = slipnet.sameness
        backwardBond = slipnet.sameness
    else:
        backwardBond = destinationDescriptor.getBondCategory(sourceDescriptor)
    assert category in [forwardBond, backwardBond]
    if category == forwardBond:
        coderack.proposeBond(source, destination, category,
                             bondFacet, sourceDescriptor,
                             destinationDescriptor, codelet)
    else:
        coderack.proposeBond(destination, source, category,
                             bondFacet, destinationDescriptor,
                             sourceDescriptor, codelet)
Exemple #2
0
def top_down_bond_scout__direction(codelet):
    direction = codelet.arguments[0]
    source = __getScoutSource(direction, localDirectionCategoryRelevance, 'bond')
    destination = chooseDirectedNeighbor(source, direction)
    assert destination
    logging.info('to object: %s' % destination)
    bondFacet = __getBondFacet(source, destination)
    sourceDescriptor, destinationDescriptor = __getDescriptors(bondFacet, source, destination)
    category = sourceDescriptor.getBondCategory(destinationDescriptor)
    assert category
    if category == slipnet.identity:
        category = slipnet.sameness
    coderack.proposeBond(source, destination, category, bondFacet, sourceDescriptor, destinationDescriptor, codelet)
Exemple #3
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))
    sourceDescriptor, destinationDescriptor = __getDescriptors(bondFacet, source, destination)
    logging.info("source descriptor: " + sourceDescriptor.name.upper())
    logging.info("destination descriptior: " + 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)