Give every WorkspaceStructure a self.ctx member variable.
...which is currently initialized "by magic"; but removing that magic will be the next step.
This commit is contained in:
@ -5,9 +5,8 @@ class Bond(WorkspaceStructure):
|
|||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(self, source, destination, bondCategory, bondFacet,
|
def __init__(self, source, destination, bondCategory, bondFacet,
|
||||||
sourceDescriptor, destinationDescriptor):
|
sourceDescriptor, destinationDescriptor):
|
||||||
from context import context as ctx
|
|
||||||
slipnet = ctx.slipnet
|
|
||||||
WorkspaceStructure.__init__(self)
|
WorkspaceStructure.__init__(self)
|
||||||
|
slipnet = self.ctx.slipnet
|
||||||
self.source = source
|
self.source = source
|
||||||
self.string = self.source.string
|
self.string = self.source.string
|
||||||
self.destination = destination
|
self.destination = destination
|
||||||
@ -30,8 +29,7 @@ class Bond(WorkspaceStructure):
|
|||||||
self.directionCategory = None
|
self.directionCategory = None
|
||||||
|
|
||||||
def flippedVersion(self):
|
def flippedVersion(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
return Bond(
|
return Bond(
|
||||||
self.destination, self.source,
|
self.destination, self.source,
|
||||||
self.category.getRelatedNode(slipnet.opposite),
|
self.category.getRelatedNode(slipnet.opposite),
|
||||||
@ -45,8 +43,7 @@ class Bond(WorkspaceStructure):
|
|||||||
self.category.name, self.leftObject, self.rightObject)
|
self.category.name, self.leftObject, self.rightObject)
|
||||||
|
|
||||||
def buildBond(self):
|
def buildBond(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
workspace.structures += [self]
|
workspace.structures += [self]
|
||||||
self.string.bonds += [self]
|
self.string.bonds += [self]
|
||||||
self.category.buffer = 100.0
|
self.category.buffer = 100.0
|
||||||
@ -61,8 +58,7 @@ class Bond(WorkspaceStructure):
|
|||||||
self.breakBond()
|
self.breakBond()
|
||||||
|
|
||||||
def breakBond(self):
|
def breakBond(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
if self in workspace.structures:
|
if self in workspace.structures:
|
||||||
workspace.structures.remove(self)
|
workspace.structures.remove(self)
|
||||||
if self in self.string.bonds:
|
if self in self.string.bonds:
|
||||||
@ -77,8 +73,7 @@ class Bond(WorkspaceStructure):
|
|||||||
def getIncompatibleCorrespondences(self):
|
def getIncompatibleCorrespondences(self):
|
||||||
# returns a list of correspondences that are incompatible with
|
# returns a list of correspondences that are incompatible with
|
||||||
# self bond
|
# self bond
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
incompatibles = []
|
incompatibles = []
|
||||||
if self.leftObject.leftmost and self.leftObject.correspondence:
|
if self.leftObject.leftmost and self.leftObject.correspondence:
|
||||||
correspondence = self.leftObject.correspondence
|
correspondence = self.leftObject.correspondence
|
||||||
@ -105,8 +100,7 @@ class Bond(WorkspaceStructure):
|
|||||||
return incompatibles
|
return incompatibles
|
||||||
|
|
||||||
def updateInternalStrength(self):
|
def updateInternalStrength(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
# bonds between objects of same type(ie. letter or group) are
|
# bonds between objects of same type(ie. letter or group) are
|
||||||
# stronger than bonds between different types
|
# stronger than bonds between different types
|
||||||
sourceGap = self.source.leftIndex != self.source.rightIndex
|
sourceGap = self.source.leftIndex != self.source.rightIndex
|
||||||
@ -157,8 +151,7 @@ class Bond(WorkspaceStructure):
|
|||||||
# returns a rough measure of the density in the string
|
# returns a rough measure of the density in the string
|
||||||
# of the same bond-category and the direction-category of
|
# of the same bond-category and the direction-category of
|
||||||
# the given bond
|
# the given bond
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
slotSum = 0.0
|
slotSum = 0.0
|
||||||
supportSum = 0.0
|
supportSum = 0.0
|
||||||
for object1 in workspace.objects:
|
for object1 in workspace.objects:
|
||||||
@ -189,10 +182,9 @@ class Bond(WorkspaceStructure):
|
|||||||
|
|
||||||
|
|
||||||
def possibleGroupBonds(bondCategory, directionCategory, bondFacet, bonds):
|
def possibleGroupBonds(bondCategory, directionCategory, bondFacet, bonds):
|
||||||
from context import context as ctx
|
|
||||||
slipnet = ctx.slipnet
|
|
||||||
result = []
|
result = []
|
||||||
for bond in bonds:
|
for bond in bonds:
|
||||||
|
slipnet = bond.ctx.slipnet
|
||||||
if (bond.category == bondCategory and
|
if (bond.category == bondCategory and
|
||||||
bond.directionCategory == directionCategory):
|
bond.directionCategory == directionCategory):
|
||||||
result += [bond]
|
result += [bond]
|
||||||
|
|||||||
@ -45,8 +45,7 @@ class Correspondence(WorkspaceStructure):
|
|||||||
return initialBond
|
return initialBond
|
||||||
|
|
||||||
def getIncompatibleBond(self):
|
def getIncompatibleBond(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
initialBond = self.extract_initial_bond()
|
initialBond = self.extract_initial_bond()
|
||||||
if not initialBond:
|
if not initialBond:
|
||||||
return None
|
return None
|
||||||
@ -68,8 +67,7 @@ class Correspondence(WorkspaceStructure):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def getIncompatibleCorrespondences(self):
|
def getIncompatibleCorrespondences(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
return [o.correspondence for o in workspace.initial.objects
|
return [o.correspondence for o in workspace.initial.objects
|
||||||
if o and self.incompatible(o.correspondence)]
|
if o and self.incompatible(o.correspondence)]
|
||||||
|
|
||||||
@ -102,8 +100,7 @@ class Correspondence(WorkspaceStructure):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def support(self):
|
def support(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
if isinstance(self.objectFromInitial, Letter):
|
if isinstance(self.objectFromInitial, Letter):
|
||||||
if self.objectFromInitial.spansString():
|
if self.objectFromInitial.spansString():
|
||||||
return 100.0
|
return 100.0
|
||||||
@ -166,8 +163,7 @@ class Correspondence(WorkspaceStructure):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def buildCorrespondence(self):
|
def buildCorrespondence(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
workspace.structures += [self]
|
workspace.structures += [self]
|
||||||
if self.objectFromInitial.correspondence:
|
if self.objectFromInitial.correspondence:
|
||||||
self.objectFromInitial.correspondence.breakCorrespondence()
|
self.objectFromInitial.correspondence.breakCorrespondence()
|
||||||
@ -202,8 +198,7 @@ class Correspondence(WorkspaceStructure):
|
|||||||
self.breakCorrespondence()
|
self.breakCorrespondence()
|
||||||
|
|
||||||
def breakCorrespondence(self):
|
def breakCorrespondence(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
workspace.structures.remove(self)
|
workspace.structures.remove(self)
|
||||||
self.objectFromInitial.correspondence = None
|
self.objectFromInitial.correspondence = None
|
||||||
self.objectFromTarget.correspondence = None
|
self.objectFromTarget.correspondence = None
|
||||||
|
|||||||
@ -15,8 +15,7 @@ class Description(WorkspaceStructure):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = 'description(%s) of %s' % (self.descriptor.get_name(), self.object)
|
s = 'description(%s) of %s' % (self.descriptor.get_name(), self.object)
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
if self.object.string == workspace.initial:
|
if self.object.string == workspace.initial:
|
||||||
s += ' in initial string'
|
s += ' in initial string'
|
||||||
else:
|
else:
|
||||||
@ -31,8 +30,7 @@ class Description(WorkspaceStructure):
|
|||||||
self.descriptionType.activation) / 2
|
self.descriptionType.activation) / 2
|
||||||
|
|
||||||
def localSupport(self):
|
def localSupport(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
described_like_self = 0
|
described_like_self = 0
|
||||||
for other in workspace.objects:
|
for other in workspace.objects:
|
||||||
if self.object == other:
|
if self.object == other:
|
||||||
@ -55,8 +53,7 @@ class Description(WorkspaceStructure):
|
|||||||
self.object.descriptions += [self]
|
self.object.descriptions += [self]
|
||||||
|
|
||||||
def breakDescription(self):
|
def breakDescription(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
if self in workspace.structures:
|
if self in workspace.structures:
|
||||||
workspace.structures.remove(self)
|
workspace.structures.remove(self)
|
||||||
self.object.descriptions.remove(self)
|
self.object.descriptions.remove(self)
|
||||||
|
|||||||
@ -9,10 +9,9 @@ class Group(WorkspaceObject):
|
|||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
def __init__(self, string, groupCategory, directionCategory, facet,
|
def __init__(self, string, groupCategory, directionCategory, facet,
|
||||||
objectList, bondList):
|
objectList, bondList):
|
||||||
from context import context as ctx
|
|
||||||
slipnet = ctx.slipnet
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
WorkspaceObject.__init__(self, string)
|
WorkspaceObject.__init__(self, string)
|
||||||
|
slipnet = self.ctx.slipnet
|
||||||
self.groupCategory = groupCategory
|
self.groupCategory = groupCategory
|
||||||
self.directionCategory = directionCategory
|
self.directionCategory = directionCategory
|
||||||
self.facet = facet
|
self.facet = facet
|
||||||
@ -42,7 +41,7 @@ class Group(WorkspaceObject):
|
|||||||
self.clampSalience = False
|
self.clampSalience = False
|
||||||
self.name = ''
|
self.name = ''
|
||||||
|
|
||||||
from description import Description
|
from description import Description # gross
|
||||||
if self.bondList and len(self.bondList):
|
if self.bondList and len(self.bondList):
|
||||||
firstFacet = self.bondList[0].facet
|
firstFacet = self.bondList[0].facet
|
||||||
self.addBondDescription(
|
self.addBondDescription(
|
||||||
@ -74,8 +73,7 @@ class Group(WorkspaceObject):
|
|||||||
|
|
||||||
def add_length_description_category(self):
|
def add_length_description_category(self):
|
||||||
#check whether or not to add length description category
|
#check whether or not to add length description category
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
probability = self.lengthDescriptionProbability()
|
probability = self.lengthDescriptionProbability()
|
||||||
if random.random() < probability:
|
if random.random() < probability:
|
||||||
length = len(self.objectList)
|
length = len(self.objectList)
|
||||||
@ -101,8 +99,7 @@ class Group(WorkspaceObject):
|
|||||||
self.bondDescriptions += [description]
|
self.bondDescriptions += [description]
|
||||||
|
|
||||||
def singleLetterGroupProbability(self):
|
def singleLetterGroupProbability(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
numberOfSupporters = self.numberOfLocalSupportingGroups()
|
numberOfSupporters = self.numberOfLocalSupportingGroups()
|
||||||
if not numberOfSupporters:
|
if not numberOfSupporters:
|
||||||
return 0.0
|
return 0.0
|
||||||
@ -115,11 +112,10 @@ class Group(WorkspaceObject):
|
|||||||
support = self.localSupport() / 100.0
|
support = self.localSupport() / 100.0
|
||||||
activation = slipnet.length.activation / 100.0
|
activation = slipnet.length.activation / 100.0
|
||||||
supportedActivation = (support * activation) ** exp
|
supportedActivation = (support * activation) ** exp
|
||||||
return formulas.temperatureAdjustedProbability(ctx, supportedActivation)
|
return formulas.temperatureAdjustedProbability(self.ctx, supportedActivation)
|
||||||
|
|
||||||
def flippedVersion(self):
|
def flippedVersion(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
flippedBonds = [b.flippedversion() for b in self.bondList]
|
flippedBonds = [b.flippedversion() for b in self.bondList]
|
||||||
flippedGroup = self.groupCategory.getRelatedNode(slipnet.flipped)
|
flippedGroup = self.groupCategory.getRelatedNode(slipnet.flipped)
|
||||||
flippedDirection = self.directionCategory.getRelatedNode(
|
flippedDirection = self.directionCategory.getRelatedNode(
|
||||||
@ -128,8 +124,7 @@ class Group(WorkspaceObject):
|
|||||||
self.facet, self.objectList, flippedBonds)
|
self.facet, self.objectList, flippedBonds)
|
||||||
|
|
||||||
def buildGroup(self):
|
def buildGroup(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
workspace.objects += [self]
|
workspace.objects += [self]
|
||||||
workspace.structures += [self]
|
workspace.structures += [self]
|
||||||
self.string.objects += [self]
|
self.string.objects += [self]
|
||||||
@ -144,15 +139,14 @@ class Group(WorkspaceObject):
|
|||||||
description.descriptor.buffer = 100.0
|
description.descriptor.buffer = 100.0
|
||||||
|
|
||||||
def lengthDescriptionProbability(self):
|
def lengthDescriptionProbability(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
length = len(self.objectList)
|
length = len(self.objectList)
|
||||||
if length > 5:
|
if length > 5:
|
||||||
return 0.0
|
return 0.0
|
||||||
cubedlength = length ** 3
|
cubedlength = length ** 3
|
||||||
fred = cubedlength * (100.0 - slipnet.length.activation) / 100.0
|
fred = cubedlength * (100.0 - slipnet.length.activation) / 100.0
|
||||||
probability = 0.5 ** fred
|
probability = 0.5 ** fred
|
||||||
value = formulas.temperatureAdjustedProbability(ctx, probability)
|
value = formulas.temperatureAdjustedProbability(self.ctx, probability)
|
||||||
if value < 0.06:
|
if value < 0.06:
|
||||||
value = 0.0 # otherwise 1/20 chance always
|
value = 0.0 # otherwise 1/20 chance always
|
||||||
return value
|
return value
|
||||||
@ -161,8 +155,7 @@ class Group(WorkspaceObject):
|
|||||||
self.breakGroup()
|
self.breakGroup()
|
||||||
|
|
||||||
def breakGroup(self):
|
def breakGroup(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
while len(self.descriptions):
|
while len(self.descriptions):
|
||||||
description = self.descriptions[-1]
|
description = self.descriptions[-1]
|
||||||
description.breakDescription()
|
description.breakDescription()
|
||||||
@ -184,8 +177,7 @@ class Group(WorkspaceObject):
|
|||||||
self.rightBond.breakBond()
|
self.rightBond.breakBond()
|
||||||
|
|
||||||
def updateInternalStrength(self):
|
def updateInternalStrength(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
relatedBondAssociation = self.groupCategory.getRelatedNode(
|
relatedBondAssociation = self.groupCategory.getRelatedNode(
|
||||||
slipnet.bondCategory).degreeOfAssociation()
|
slipnet.bondCategory).degreeOfAssociation()
|
||||||
bondWeight = relatedBondAssociation ** 0.98
|
bondWeight = relatedBondAssociation ** 0.98
|
||||||
@ -247,8 +239,7 @@ class Group(WorkspaceObject):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def morePossibleDescriptions(self, node):
|
def morePossibleDescriptions(self, node):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
result = []
|
result = []
|
||||||
for i, number in enumerate(slipnet.numbers, 1):
|
for i, number in enumerate(slipnet.numbers, 1):
|
||||||
if node == number and len(self.objects) == i:
|
if node == number and len(self.objects) == i:
|
||||||
|
|||||||
@ -3,9 +3,8 @@ from workspaceObject import WorkspaceObject
|
|||||||
|
|
||||||
class Letter(WorkspaceObject):
|
class Letter(WorkspaceObject):
|
||||||
def __init__(self, string, position, length):
|
def __init__(self, string, position, length):
|
||||||
from context import context as ctx
|
|
||||||
workspace = ctx.workspace
|
|
||||||
WorkspaceObject.__init__(self, string)
|
WorkspaceObject.__init__(self, string)
|
||||||
|
workspace = self.ctx.workspace
|
||||||
workspace.objects += [self]
|
workspace.objects += [self]
|
||||||
string.objects += [self]
|
string.objects += [self]
|
||||||
self.leftIndex = position
|
self.leftIndex = position
|
||||||
@ -14,8 +13,7 @@ class Letter(WorkspaceObject):
|
|||||||
self.rightmost = self.rightIndex == length
|
self.rightmost = self.rightIndex == length
|
||||||
|
|
||||||
def describe(self, position, length):
|
def describe(self, position, length):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
if length == 1:
|
if length == 1:
|
||||||
self.addDescription(slipnet.stringPositionCategory,
|
self.addDescription(slipnet.stringPositionCategory,
|
||||||
slipnet.single)
|
slipnet.single)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import logging
|
|||||||
|
|
||||||
|
|
||||||
from workspaceStructure import WorkspaceStructure
|
from workspaceStructure import WorkspaceStructure
|
||||||
from formulas import weightedAverage
|
import formulas
|
||||||
|
|
||||||
|
|
||||||
class Rule(WorkspaceStructure):
|
class Rule(WorkspaceStructure):
|
||||||
@ -24,8 +24,7 @@ class Rule(WorkspaceStructure):
|
|||||||
self.externalStrength = self.internalStrength
|
self.externalStrength = self.internalStrength
|
||||||
|
|
||||||
def updateInternalStrength(self):
|
def updateInternalStrength(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
if not (self.descriptor and self.relation):
|
if not (self.descriptor and self.relation):
|
||||||
self.internalStrength = 0.0
|
self.internalStrength = 0.0
|
||||||
return
|
return
|
||||||
@ -53,7 +52,7 @@ class Rule(WorkspaceStructure):
|
|||||||
weights = ((depthDifference, 12),
|
weights = ((depthDifference, 12),
|
||||||
(averageDepth, 18),
|
(averageDepth, 18),
|
||||||
(sharedDescriptorTerm, sharedDescriptorWeight))
|
(sharedDescriptorTerm, sharedDescriptorWeight))
|
||||||
self.internalStrength = weightedAverage(weights)
|
self.internalStrength = formulas.weightedAverage(weights)
|
||||||
if self.internalStrength > 100.0:
|
if self.internalStrength > 100.0:
|
||||||
self.internalStrength = 100.0
|
self.internalStrength = 100.0
|
||||||
|
|
||||||
@ -81,8 +80,7 @@ class Rule(WorkspaceStructure):
|
|||||||
self.descriptor.buffer = 100.0
|
self.descriptor.buffer = 100.0
|
||||||
|
|
||||||
def incompatibleRuleCorrespondence(self, correspondence):
|
def incompatibleRuleCorrespondence(self, correspondence):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
if not correspondence:
|
if not correspondence:
|
||||||
return False
|
return False
|
||||||
# find changed object
|
# find changed object
|
||||||
@ -97,8 +95,7 @@ class Rule(WorkspaceStructure):
|
|||||||
for m in correspondence.conceptMappings)
|
for m in correspondence.conceptMappings)
|
||||||
|
|
||||||
def __changeString(self, string):
|
def __changeString(self, string):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
# applies the changes to self string ie. successor
|
# applies the changes to self string ie. successor
|
||||||
if self.facet == slipnet.length:
|
if self.facet == slipnet.length:
|
||||||
if self.relation == slipnet.predecessor:
|
if self.relation == slipnet.predecessor:
|
||||||
@ -119,8 +116,7 @@ class Rule(WorkspaceStructure):
|
|||||||
return self.relation.name.lower()
|
return self.relation.name.lower()
|
||||||
|
|
||||||
def buildTranslatedRule(self):
|
def buildTranslatedRule(self):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
slippages = workspace.slippages()
|
slippages = workspace.slippages()
|
||||||
self.category = self.category.applySlippages(slippages)
|
self.category = self.category.applySlippages(slippages)
|
||||||
self.facet = self.facet.applySlippages(slippages)
|
self.facet = self.facet.applySlippages(slippages)
|
||||||
|
|||||||
@ -49,8 +49,7 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
self.descriptions += [description]
|
self.descriptions += [description]
|
||||||
|
|
||||||
def addDescriptions(self, descriptions):
|
def addDescriptions(self, descriptions):
|
||||||
from context import context as ctx
|
workspace = self.ctx.workspace
|
||||||
workspace = ctx.workspace
|
|
||||||
copy = descriptions[:] # in case we add to our own descriptions
|
copy = descriptions[:] # in case we add to our own descriptions
|
||||||
for description in copy:
|
for description in copy:
|
||||||
logging.info('might add: %s', description)
|
logging.info('might add: %s', description)
|
||||||
@ -124,8 +123,7 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
|
|
||||||
def getPossibleDescriptions(self, descriptionType):
|
def getPossibleDescriptions(self, descriptionType):
|
||||||
from group import Group # gross, TODO FIXME
|
from group import Group # gross, TODO FIXME
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
logging.info('getting possible descriptions for %s', self)
|
logging.info('getting possible descriptions for %s', self)
|
||||||
descriptions = []
|
descriptions = []
|
||||||
for link in descriptionType.instanceLinks:
|
for link in descriptionType.instanceLinks:
|
||||||
@ -170,13 +168,11 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
return objectOnMyRightIsRightmost and objectOnMyLeftIsLeftmost
|
return objectOnMyRightIsRightmost and objectOnMyLeftIsLeftmost
|
||||||
|
|
||||||
def distinguishingDescriptor(self, descriptor):
|
def distinguishingDescriptor(self, descriptor):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
return slipnet.isDistinguishingDescriptor(descriptor)
|
return slipnet.isDistinguishingDescriptor(descriptor)
|
||||||
|
|
||||||
def relevantDistinguishingDescriptors(self):
|
def relevantDistinguishingDescriptors(self):
|
||||||
from context import context as ctx
|
slipnet = self.ctx.slipnet
|
||||||
slipnet = ctx.slipnet
|
|
||||||
return [d.descriptor
|
return [d.descriptor
|
||||||
for d in self.relevantDescriptions()
|
for d in self.relevantDescriptions()
|
||||||
if slipnet.isDistinguishingDescriptor(d.descriptor)]
|
if slipnet.isDistinguishingDescriptor(d.descriptor)]
|
||||||
|
|||||||
@ -8,6 +8,8 @@ def abstract_call(objekt, name):
|
|||||||
|
|
||||||
class WorkspaceStructure(object):
|
class WorkspaceStructure(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
from context import context as ctx
|
||||||
|
self.ctx = ctx
|
||||||
self.string = None
|
self.string = None
|
||||||
self.internalStrength = 0.0
|
self.internalStrength = 0.0
|
||||||
self.externalStrength = 0.0
|
self.externalStrength = 0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user