diff --git a/copycat/bond.py b/copycat/bond.py index 7dcaf6c..456aff6 100644 --- a/copycat/bond.py +++ b/copycat/bond.py @@ -3,9 +3,8 @@ from workspaceStructure import WorkspaceStructure class Bond(WorkspaceStructure): # pylint: disable=too-many-arguments - def __init__(self, source, destination, bondCategory, bondFacet, + def __init__(self, ctx, source, destination, bondCategory, bondFacet, sourceDescriptor, destinationDescriptor): - from context import context as ctx WorkspaceStructure.__init__(self, ctx) slipnet = self.ctx.slipnet self.source = source @@ -31,7 +30,7 @@ class Bond(WorkspaceStructure): def flippedVersion(self): slipnet = self.ctx.slipnet - return Bond( + return Bond(self.ctx, self.destination, self.source, self.category.getRelatedNode(slipnet.opposite), self.facet, self.destinationDescriptor, self.sourceDescriptor) @@ -198,7 +197,7 @@ def possibleGroupBonds(bondCategory, directionCategory, bondFacet, bonds): return None # a different bond cannot be made here if bond.category == slipnet.sameness: return None - bond = Bond(bond.destination, bond.source, bondCategory, + bond = Bond(bond.ctx, bond.destination, bond.source, bondCategory, bondFacet, bond.destinationDescriptor, bond.sourceDescriptor) result += [bond] diff --git a/copycat/codeletMethods.py b/copycat/codeletMethods.py index a1edcbf..ddefb0c 100644 --- a/copycat/codeletMethods.py +++ b/copycat/codeletMethods.py @@ -351,7 +351,7 @@ def replacement_finder(ctx, codelet): else: relation = None logging.info('no relation found') - letterOfInitialString.replacement = Replacement( + letterOfInitialString.replacement = Replacement(ctx, letterOfInitialString, letterOfModifiedString, relation) if relation != slipnet.sameness: letterOfInitialString.changed = True @@ -777,7 +777,7 @@ def group_builder(ctx, codelet): destination = object1 category = group.groupCategory.getRelatedNode(slipnet.bondCategory) facet = group.facet - newBond = Bond(source, destination, category, facet, + newBond = Bond(ctx, source, destination, category, facet, source.getDescriptor(facet), destination.getDescriptor(facet)) newBond.buildBond() diff --git a/copycat/coderack.py b/copycat/coderack.py index a721389..a97f39f 100644 --- a/copycat/coderack.py +++ b/copycat/coderack.py @@ -197,7 +197,7 @@ class Coderack(object): The new codelet has urgency a function of the degree of conceptual-depth of the descriptions in the rule """ - rule = Rule(facet, description, category, relation) + rule = Rule(self.ctx, facet, description, category, relation) rule.updateStrength() if description and relation: depths = description.conceptualDepth + relation.conceptualDepth @@ -209,7 +209,7 @@ class Coderack(object): def proposeCorrespondence(self, initialObject, targetObject, conceptMappings, flipTargetObject, oldCodelet): - correspondence = Correspondence(initialObject, targetObject, + correspondence = Correspondence(self.ctx, initialObject, targetObject, conceptMappings, flipTargetObject) for mapping in conceptMappings: mapping.initialDescriptionType.buffer = 100.0 @@ -256,7 +256,7 @@ class Coderack(object): bondFacet.buffer = 100.0 sourceDescriptor.buffer = 100.0 destinationDescriptor.buffer = 100.0 - bond = Bond(source, destination, bondCategory, bondFacet, + bond = Bond(self.ctx, source, destination, bondCategory, bondFacet, sourceDescriptor, destinationDescriptor) urgency = bondCategory.bondDegreeOfAssociation() self.newCodelet('bond-strength-tester', oldCodelet, urgency, bond) diff --git a/copycat/correspondence.py b/copycat/correspondence.py index 1feacb7..d77b579 100644 --- a/copycat/correspondence.py +++ b/copycat/correspondence.py @@ -5,9 +5,8 @@ import formulas class Correspondence(WorkspaceStructure): - def __init__(self, objectFromInitial, objectFromTarget, + def __init__(self, ctx, objectFromInitial, objectFromTarget, conceptMappings, flipTargetObject): - from context import context as ctx WorkspaceStructure.__init__(self, ctx) self.objectFromInitial = objectFromInitial self.objectFromTarget = objectFromTarget diff --git a/copycat/description.py b/copycat/description.py index aa1bf44..2c7eaf9 100644 --- a/copycat/description.py +++ b/copycat/description.py @@ -4,8 +4,7 @@ from workspaceStructure import WorkspaceStructure class Description(WorkspaceStructure): def __init__(self, workspaceObject, descriptionType, descriptor): - from context import context as ctx - WorkspaceStructure.__init__(self, ctx) + WorkspaceStructure.__init__(self, workspaceObject.ctx) self.object = workspaceObject self.string = workspaceObject.string self.descriptionType = descriptionType diff --git a/copycat/replacement.py b/copycat/replacement.py index 3f21c05..690b131 100644 --- a/copycat/replacement.py +++ b/copycat/replacement.py @@ -2,8 +2,7 @@ from workspaceStructure import WorkspaceStructure class Replacement(WorkspaceStructure): - def __init__(self, objectFromInitial, objectFromModified, relation): - from context import context as ctx + def __init__(self, ctx, objectFromInitial, objectFromModified, relation): WorkspaceStructure.__init__(self, ctx) self.objectFromInitial = objectFromInitial self.objectFromModified = objectFromModified diff --git a/copycat/rule.py b/copycat/rule.py index c7cfb78..205df03 100644 --- a/copycat/rule.py +++ b/copycat/rule.py @@ -6,8 +6,7 @@ import formulas class Rule(WorkspaceStructure): - def __init__(self, facet, descriptor, category, relation): - from context import context as ctx + def __init__(self, ctx, facet, descriptor, category, relation): WorkspaceStructure.__init__(self, ctx) self.facet = facet self.descriptor = descriptor