本文整理汇总了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)