Smartness update! A single letter is both "leftmost" and "rightmost".
Before this change, Copycat was unable to formulate more than the empty rule for
abc : abd :: f : f
abc : dbc :: f : f
abc : aac :: f : f
After this change, Copycat strongly prefers
abc : abd :: f : g ("Replace the rightmost letter with its successor")
abc : dbc :: f : d ("Replace the leftmost letter with d")
abc : aac :: f : e ("Replace the middle letter with its predecessor")
This commit is contained in:
@ -15,17 +15,13 @@ class Letter(WorkspaceObject):
|
||||
def describe(self, position, length):
|
||||
slipnet = self.ctx.slipnet
|
||||
if length == 1:
|
||||
self.addDescription(slipnet.stringPositionCategory,
|
||||
slipnet.single)
|
||||
if self.leftmost and length > 1: # ? why check length ?
|
||||
self.addDescription(slipnet.stringPositionCategory,
|
||||
slipnet.leftmost)
|
||||
if self.rightmost and length > 1: # ? why check length ?
|
||||
self.addDescription(slipnet.stringPositionCategory,
|
||||
slipnet.rightmost)
|
||||
if length > 2 and position * 2 == length + 1:
|
||||
self.addDescription(slipnet.stringPositionCategory,
|
||||
slipnet.middle)
|
||||
self.addDescription(slipnet.stringPositionCategory, slipnet.single)
|
||||
if self.leftmost:
|
||||
self.addDescription(slipnet.stringPositionCategory, slipnet.leftmost)
|
||||
if self.rightmost:
|
||||
self.addDescription(slipnet.stringPositionCategory, slipnet.rightmost)
|
||||
if position * 2 == length + 1:
|
||||
self.addDescription(slipnet.stringPositionCategory, slipnet.middle)
|
||||
|
||||
def __repr__(self):
|
||||
return '<Letter: %s>' % self.__str__()
|
||||
|
||||
Reference in New Issue
Block a user