Пример #1
0
    def __init__(self, string, groupCategory, directionCategory, facet, objectList, bondList):
        WorkspaceObject.__init__(self, string)
        self.groupCategory = groupCategory
        self.directionCategory = directionCategory
        self.facet = facet
        self.objectList = objectList
        self.bondList = bondList
        self.bondCategory = self.groupCategory.getRelatedNode(slipnet.bondCategory)

        leftObject = objectList[0]
        rightObject = objectList[-1]
        self.leftStringPosition = leftObject.leftStringPosition
        self.leftmost = self.leftStringPosition == 1
        self.rightStringPosition = rightObject.rightStringPosition
        self.rightmost = self.rightStringPosition == len(self.string)

        self.descriptions = []
        self.bondDescriptions = []
        self.extrinsicDescriptions = []
        self.outgoingBonds = []
        self.incomingBonds = []
        self.bonds = []
        self.leftBond = None
        self.rightBond = None
        self.correspondence = None
        self.changed = False
        self.newAnswerLetter = False
        self.clampSalience = False
        self.name = ''

        from description import Description
        if self.bondList and len(self.bondList):
            firstFacet = self.bondList[0].facet
            self.addBondDescription(Description(self, slipnet.bondFacet, firstFacet))
        self.addBondDescription(Description(self, slipnet.bondCategory, self.bondCategory))

        self.addDescription(slipnet.objectCategory, slipnet.group)
        self.addDescription(slipnet.groupCategory, self.groupCategory)
        if not self.directionCategory:
            # sameness group - find letterCategory
            letter = self.objectList[0].getDescriptor(self.facet)
            self.addDescription(self.facet, letter)
        if self.directionCategory:
            self.addDescription(slipnet.directionCategory, self.directionCategory)
        if self.spansString():
            self.addDescription(slipnet.stringPositionCategory, slipnet.whole)
        elif self.leftStringPosition == 1:
            self.addDescription(slipnet.stringPositionCategory, slipnet.leftmost)
        elif self.rightStringPosition == self.string.length:
            self.addDescription(slipnet.stringPositionCategory, slipnet.rightmost)
        elif self.middleObject():
            self.addDescription(slipnet.stringPositionCategory, slipnet.middle)

        #check whether or not to add length description category
        probability = self.lengthDescriptionProbability()
        if random.random() < probability:
            length = len(self.objectList)
            if length < 6:
                self.addDescription(slipnet.length, slipnet.numbers[length - 1])
Пример #2
0
 def __init__(self, string, position, length):
     WorkspaceObject.__init__(self, string)
     from workspace import workspace
     workspace.objects += [self]
     string.objects += [self]
     self.leftIndex = position
     self.leftmost = self.leftIndex == 1
     self.rightIndex = position
     self.rightmost = self.rightIndex == length
Пример #3
0
 def __init__(self, string, position, length):
     WorkspaceObject.__init__(self, string)
     from workspace import workspace
     workspace.objects += [self]
     string.objects += [self]
     self.leftIndex = position
     self.leftmost = self.leftIndex == 1
     self.rightIndex = position
     self.rightmost = self.rightIndex == length
Пример #4
0
 def distinguishingDescriptor(self, descriptor):
     """Whether no other object of the same type has the same descriptor"""
     if not WorkspaceObject.distinguishingDescriptor(self, descriptor):
         return False
     for objekt in self.string.objects:
         # check to see if they are of the same type
         if isinstance(objekt, Letter) and objekt != self:
             # check all descriptions for the descriptor
             for description in objekt.descriptions:
                 if description.descriptor == descriptor:
                     return False
     return True
Пример #5
0
 def distinguishingDescriptor(self, descriptor):
     """Whether no other object of the same type has the same descriptor"""
     if not WorkspaceObject.distinguishingDescriptor(self, descriptor):
         return False
     for objekt in self.string.objects:
         # check to see if they are of the same type
         if isinstance(objekt, Letter) and objekt != self:
             # check all descriptions for the descriptor
             for description in objekt.descriptions:
                 if description.descriptor == descriptor:
                     return False
     return True
Пример #6
0
    def __init__(self, string, groupCategory, directionCategory, facet,
                 objectList, bondList):
        # pylint: disable=too-many-arguments
        WorkspaceObject.__init__(self, string)
        self.groupCategory = groupCategory
        self.directionCategory = directionCategory
        self.facet = facet
        self.objectList = objectList
        self.bondList = bondList
        self.bondCategory = self.groupCategory.getRelatedNode(
            slipnet.bondCategory)

        leftObject = objectList[0]
        rightObject = objectList[-1]
        self.leftIndex = leftObject.leftIndex
        self.leftmost = self.leftIndex == 1
        self.rightIndex = rightObject.rightIndex
        self.rightmost = self.rightIndex == len(self.string)

        self.descriptions = []
        self.bondDescriptions = []
        self.extrinsicDescriptions = []
        self.outgoingBonds = []
        self.incomingBonds = []
        self.bonds = []
        self.leftBond = None
        self.rightBond = None
        self.correspondence = None
        self.changed = False
        self.newAnswerLetter = False
        self.clampSalience = False
        self.name = ''

        from description import Description
        if self.bondList and len(self.bondList):
            firstFacet = self.bondList[0].facet
            self.addBondDescription(
                Description(self, slipnet.bondFacet, firstFacet))
        self.addBondDescription(
            Description(self, slipnet.bondCategory, self.bondCategory))

        self.addDescription(slipnet.objectCategory, slipnet.group)
        self.addDescription(slipnet.groupCategory, self.groupCategory)
        if not self.directionCategory:
            # sameness group - find letterCategory
            letter = self.objectList[0].getDescriptor(self.facet)
            self.addDescription(self.facet, letter)
        if self.directionCategory:
            self.addDescription(slipnet.directionCategory,
                                self.directionCategory)
        if self.spansString():
            self.addDescription(slipnet.stringPositionCategory, slipnet.whole)
        elif self.leftIndex == 1:
            self.addDescription(slipnet.stringPositionCategory,
                                slipnet.leftmost)
        elif self.rightIndex == self.string.length:
            self.addDescription(slipnet.stringPositionCategory,
                                slipnet.rightmost)
        elif self.middleObject():
            self.addDescription(slipnet.stringPositionCategory, slipnet.middle)
        self.add_length_description_category()
Пример #7
0
    def __init__(self, string, groupCategory, directionCategory, facet,
                 objectList, bondList):
        WorkspaceObject.__init__(self, string)
        self.groupCategory = groupCategory
        self.directionCategory = directionCategory
        self.facet = facet
        self.objectList = objectList
        self.bondList = bondList
        self.bondCategory = self.groupCategory.getRelatedNode(
            slipnet.bondCategory)

        leftObject = objectList[0]
        rightObject = objectList[-1]
        self.leftStringPosition = leftObject.leftStringPosition
        self.leftmost = self.leftStringPosition == 1
        self.rightStringPosition = rightObject.rightStringPosition
        self.rightmost = self.rightStringPosition == len(self.string)

        self.descriptions = []
        self.bondDescriptions = []
        self.extrinsicDescriptions = []
        self.outgoingBonds = []
        self.incomingBonds = []
        self.bonds = []
        self.leftBond = None
        self.rightBond = None
        self.correspondence = None
        self.changed = False
        self.newAnswerLetter = False
        self.clampSalience = False
        self.name = ''

        from description import Description
        if self.bondList and len(self.bondList):
            firstFacet = self.bondList[0].facet
            self.addBondDescription(
                Description(self, slipnet.bondFacet, firstFacet))
        self.addBondDescription(
            Description(self, slipnet.bondCategory, self.bondCategory))

        self.addDescription(slipnet.objectCategory, slipnet.group)
        self.addDescription(slipnet.groupCategory, self.groupCategory)
        if not self.directionCategory:
            # sameness group - find letterCategory
            letter = self.objectList[0].getDescriptor(self.facet)
            self.addDescription(self.facet, letter)
        if self.directionCategory:
            self.addDescription(slipnet.directionCategory,
                                self.directionCategory)
        if self.spansString():
            self.addDescription(slipnet.stringPositionCategory, slipnet.whole)
        elif self.leftStringPosition == 1:
            self.addDescription(slipnet.stringPositionCategory,
                                slipnet.leftmost)
        elif self.rightStringPosition == self.string.length:
            self.addDescription(slipnet.stringPositionCategory,
                                slipnet.rightmost)
        elif self.middleObject():
            self.addDescription(slipnet.stringPositionCategory, slipnet.middle)

        #check whether or not to add length description category
        probability = self.lengthDescriptionProbability()
        if random.random() < probability:
            length = len(self.objectList)
            if length < 6:
                self.addDescription(slipnet.length,
                                    slipnet.numbers[length - 1])
Пример #8
0
    def __init__(self, string, groupCategory, directionCategory, facet,
                 objectList, bondList):
        # pylint: disable=too-many-arguments
        WorkspaceObject.__init__(self, string)
        self.groupCategory = groupCategory
        self.directionCategory = directionCategory
        self.facet = facet
        self.objectList = objectList
        self.bondList = bondList
        self.bondCategory = self.groupCategory.getRelatedNode(
            slipnet.bondCategory)

        leftObject = objectList[0]
        rightObject = objectList[-1]
        self.leftIndex = leftObject.leftIndex
        self.leftmost = self.leftIndex == 1
        self.rightIndex = rightObject.rightIndex
        self.rightmost = self.rightIndex == len(self.string)

        self.descriptions = []
        self.bondDescriptions = []
        self.extrinsicDescriptions = []
        self.outgoingBonds = []
        self.incomingBonds = []
        self.bonds = []
        self.leftBond = None
        self.rightBond = None
        self.correspondence = None
        self.changed = False
        self.newAnswerLetter = False
        self.clampSalience = False
        self.name = ''

        from description import Description
        if self.bondList and len(self.bondList):
            firstFacet = self.bondList[0].facet
            self.addBondDescription(
                Description(self, slipnet.bondFacet, firstFacet))
        self.addBondDescription(
            Description(self, slipnet.bondCategory, self.bondCategory))

        self.addDescription(slipnet.objectCategory, slipnet.group)
        self.addDescription(slipnet.groupCategory, self.groupCategory)
        if not self.directionCategory:
            # sameness group - find letterCategory
            letter = self.objectList[0].getDescriptor(self.facet)
            self.addDescription(self.facet, letter)
        if self.directionCategory:
            self.addDescription(slipnet.directionCategory,
                                self.directionCategory)
        if self.spansString():
            self.addDescription(slipnet.stringPositionCategory, slipnet.whole)
        elif self.leftIndex == 1:
            self.addDescription(
                slipnet.stringPositionCategory, slipnet.leftmost)
        elif self.rightIndex == self.string.length:
            self.addDescription(
                slipnet.stringPositionCategory, slipnet.rightmost)
        elif self.middleObject():
            self.addDescription(
                slipnet.stringPositionCategory, slipnet.middle)
        self.add_length_description_category()