Example #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)
Example #2
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)