#REFACTORING by exept
class: PhoneticStringUtilities::DoubleMetaphoneStringComparator
changed:
#processC
#processG
--- a/PhoneticStringUtilities.st Sun Feb 23 11:37:55 2020 +0100
+++ b/PhoneticStringUtilities.st Sun Feb 23 11:48:49 2020 +0100
@@ -1482,13 +1482,13 @@
^self ].
(currentIndex = 1 "b"
- and: [ (inputKey size > 5 and: [(inputKey copyFrom: 1 to: 6) = 'CHARAC'
- or: [ (inputKey copyFrom: 1 to: 6) = 'CHARIS' ]] )
- or: [inputKey size > 4 and: [ ((((inputKey copyFrom: 1 to: 4) = 'CHOR'
- or: [ (inputKey copyFrom: 1 to: 4) = 'CHYM' ])
- or: [ (inputKey copyFrom: 1 to: 4) = 'CHIA' ])
- or: [ (inputKey copyFrom: 1 to: 4) = 'CHEM' ])
- and: [ (inputKey copyFrom: 1 to: 4) ~= 'CHORE' ] ] ] ])
+ and: [ (inputKey size > 5 and: [(inputKey startsWith: 'CHARAC')
+ or: [ (inputKey startsWith: 'CHARIS') ]] )
+ or: [inputKey size > 4 and: [ ((((inputKey startsWith: 'CHOR')
+ or: [ (inputKey startsWith: 'CHYM') ])
+ or: [ (inputKey startsWith: 'CHIA') ])
+ or: [ (inputKey startsWith: 'CHEM') ])
+ and: [ (inputKey startsWith: 'CHORE') not ] ] ] ])
ifTrue: [ self
addPrimaryTranslation: 'K';
addSecondaryTranslation: 'K'.
@@ -1496,7 +1496,7 @@
^self ].
(((((#('VAN ' 'VON ') includes: (inputKey copyFrom: 1 to: 4)) "c"
- or: [ (inputKey copyFrom: 1 to: 3) = 'SCH' ])
+ or: [ (inputKey startsWith: 'SCH') ])
or: [ #('ORCHES' 'ARCHIT' 'ORCHID')
includes: (self keyMidString: 6 from: currentIndex-2) ])
or: [ #($T $S) includes: (self keyAt: currentIndex+2) ])
@@ -1512,7 +1512,7 @@
ifFalse:
[ currentIndex > 1
ifTrue:
- [ (inputKey copyFrom: 1 to: 2) = 'MC'
+ [ (inputKey startsWith: 'MC')
ifTrue:
[ self
addPrimaryTranslation: 'K';
@@ -1847,7 +1847,7 @@
if((StringAt(0, 4, VAN , VON , ) OR StringAt(0, 3, SCH, ))
OR StringAt((current + 1), 2, ET, )) MetaphAdd(K);"
word := (inputKey copyFrom: 1 to: 4).
- ((#('VAN ' 'VON ') includes: word) or: [(word copyFrom: 1 to: 3) = 'SCH' or: [(word copyFrom: 1 to: 2) = 'ET']])
+ ((#('VAN ' 'VON ') includes: word) or: [(word startsWith: 'SCH') or: [(word startsWith: 'ET')]])
ifTrue: [
self addPrimaryTranslation: 'K';
addSecondaryTranslation: 'K'.
@@ -1859,7 +1859,7 @@
MetaphAdd(J, K);
current += 2;
break;"
- (((inputKey copyFrom: currentIndex + 1 to: (currentIndex + 5 min: inputKey size)), ' ') copyFrom: 1 to: 4) = 'IER '
+ (((inputKey copyFrom: currentIndex + 1 to: (currentIndex + 5 min: inputKey size)), ' ') startsWith: 'IER ')
ifTrue: [
self addPrimaryTranslation: 'J';
addSecondaryTranslation: 'J'.