当前位置: 首页>>代码示例>>Python>>正文


Python Group.singleLetterGroupProbability方法代码示例

本文整理汇总了Python中group.Group.singleLetterGroupProbability方法的典型用法代码示例。如果您正苦于以下问题:Python Group.singleLetterGroupProbability方法的具体用法?Python Group.singleLetterGroupProbability怎么用?Python Group.singleLetterGroupProbability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在group.Group的用法示例。


在下文中一共展示了Group.singleLetterGroupProbability方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: top_down_group_scout__category

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import singleLetterGroupProbability [as 别名]
def top_down_group_scout__category(codelet):
    groupCategory = codelet.arguments[0]
    category = groupCategory.getRelatedNode(slipnet.bondCategory)
    assert category
    source = __getScoutSource(category, formulas.localBondCategoryRelevance,
                              'group')
    assert source
    assert not source.spansString()
    if source.leftmost:
        direction = slipnet.right
    elif source.rightmost:
        direction = slipnet.left
    else:
        activations = [slipnet.left.activation]
        activations += [slipnet.right.activation]
        if not formulas.selectListPosition(activations):
            direction = slipnet.left
        else:
            direction = slipnet.right
    if direction == slipnet.left:
        firstBond = source.leftBond
    else:
        firstBond = source.rightBond
    if not firstBond or firstBond.category != category:
        # check the other side of object
        if direction == slipnet.right:
            firstBond = source.leftBond
        else:
            firstBond = source.rightBond
        if not firstBond or firstBond.category != category:
            if category == slipnet.sameness and isinstance(source, Letter):
                group = Group(source.string, slipnet.samenessGroup,
                              None, slipnet.letterCategory, [source], [])
                probability = group.singleLetterGroupProbability()
                assert random.random() >= probability
                coderack.proposeSingleLetterGroup(source, codelet)
        return
    direction = firstBond.directionCategory
    search = True
    bondFacet = None
    # find leftmost object in group with these bonds
    while search:
        search = False
        if not source.leftBond:
            continue
        if source.leftBond.category != category:
            continue
        if source.leftBond.directionCategory != direction:
            if source.leftBond.directionCategory:
                continue
        if not bondFacet or bondFacet == source.leftBond.facet:
            bondFacet = source.leftBond.facet
            direction = source.leftBond.directionCategory
            source = source.leftBond.leftObject
            search = True
    # find rightmost object in group with these bonds
    search = True
    destination = source
    while search:
        search = False
        if not destination.rightBond:
            continue
        if destination.rightBond.category != category:
            continue
        if destination.rightBond.directionCategory != direction:
            if destination.rightBond.directionCategory:
                continue
        if not bondFacet or bondFacet == destination.rightBond.facet:
            bondFacet = destination.rightBond.facet
            direction = source.rightBond.directionCategory
            destination = destination.rightBond.rightObject
            search = True
    assert destination != source
    objects = [source]
    bonds = []
    while source != destination:
        bonds += [source.rightBond]
        objects += [source.rightBond.rightObject]
        source = source.rightBond.rightObject
    coderack.proposeGroup(objects, bonds, groupCategory,
                          direction, bondFacet, codelet)
开发者ID:jalanb,项目名称:co.py.cat,代码行数:83,代码来源:codeletMethods.py


注:本文中的group.Group.singleLetterGroupProbability方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。