DoWhatIMeanSupport.st
changeset 5360 b258afc07129
parent 5324 555436a71f8d
child 5361 b28af152e637
child 5368 1b5ca0f20be5
equal deleted inserted replaced
5355:067fb3525c5f 5360:b258afc07129
  3229 
  3229 
  3230                 "/ bump the weight-factor if the name string is included
  3230                 "/ bump the weight-factor if the name string is included
  3231                 (each includesString:nm) ifTrue:[
  3231                 (each includesString:nm) ifTrue:[
  3232                     (each startsWith:nm) ifTrue:[
  3232                     (each startsWith:nm) ifTrue:[
  3233                         factor := 6 * weight * nm size.
  3233                         factor := 6 * weight * nm size.
  3234                     ] ifFalse:[
  3234                     ] ifFalse:[ 
  3235                         nm size > 1 ifTrue:[
  3235                         (each endsWith:nm) ifTrue:[
  3236                             factor := 4 * weight * nm size
  3236                             factor := 5 * weight * nm size.
       
  3237                         ] ifFalse:[
       
  3238                             nm size > 1 ifTrue:[
       
  3239                                 factor := 4 * weight * nm size
       
  3240                             ].    
  3237                         ].    
  3241                         ].    
  3238                     ].    
  3242                     ].    
  3239                 ] ifFalse:[
  3243                 ] ifFalse:[
  3240                     (each includesString:nm caseSensitive:false) ifTrue:[
  3244                     (each includesString:nm caseSensitive:false) ifTrue:[
  3241                         (each asLowercase startsWith:nm asLowercase) ifTrue:[
  3245                         (each asLowercase startsWith:nm asLowercase) ifTrue:[
  3242                             factor := 4 * weight * nm size.
  3246                             factor := 4 * weight * nm size.
  3243                         ] ifFalse:[
  3247                         ] ifFalse:[
  3244                             nm size > 1 ifTrue:[
  3248                             (each asLowercase endsWith:nm asLowercase) ifTrue:[
  3245                                 factor := 2 * weight * nm size.
  3249                                 factor := 3 * weight * nm size.
       
  3250                             ] ifFalse:[
       
  3251                                 nm size > 1 ifTrue:[
       
  3252                                     factor := 2 * weight * nm size.
       
  3253                                 ]
  3246                             ]
  3254                             ]
  3247                         ]
  3255                         ]
  3248                     ]
  3256                     ]
  3249                 ].    
  3257                 ].    
  3250                 dist := dist + (weight*factor).
  3258                 dist := dist + (weight*factor).
  3607 
  3615 
  3608     allTheBest := allDistances.
  3616     allTheBest := allDistances.
  3609 
  3617 
  3610     nameIsOK ifTrue:[
  3618     nameIsOK ifTrue:[
  3611         "/ if the name already exists, only allow longer names, if there are
  3619         "/ if the name already exists, only allow longer names, if there are
  3612         longerNames := allTheBest select:[:assoc | assoc key startsWith:nm].
  3620         longerNames := allTheBest select:[:assoc | (assoc key startsWith:nm) or:[assoc key endsWith:nm]].
  3613         longerNames size < 30 ifTrue:[
  3621         longerNames size < 30 ifTrue:[
  3614             longerNames := allTheBest select:[:assoc | assoc key includesString:nm caseSensitive:false].
  3622             longerNames := allTheBest select:[:assoc | assoc key includesString:nm caseSensitive:false].
  3615         ].
  3623         ].
  3616         longerNames isEmpty ifTrue:[
  3624         longerNames isEmpty ifTrue:[
  3617             "/ no better name
  3625             "/ no better name
  5210                 (each startsWith:nm) ifTrue:[
  5218                 (each startsWith:nm) ifTrue:[
  5211                     factor := 6 * nm size.
  5219                     factor := 6 * nm size.
  5212                 ] ifFalse:[
  5220                 ] ifFalse:[
  5213                     (each asLowercase startsWith:nm asLowercase) ifTrue:[
  5221                     (each asLowercase startsWith:nm asLowercase) ifTrue:[
  5214                         factor := 4 * nm size.
  5222                         factor := 4 * nm size.
  5215                     ].
  5223                     ] ifFalse:[
       
  5224                         (each endsWith:nm) ifTrue:[
       
  5225                             factor := 3 * nm size.
       
  5226                         ] ifFalse:[
       
  5227                             (each asLowercase endsWith:nm asLowercase) ifTrue:[
       
  5228                                 factor := 2 * nm size.
       
  5229                             ]    
       
  5230                         ]    
       
  5231                     ]    
  5216                 ].
  5232                 ].
  5217                 dist := dist + (weight*factor).
  5233                 dist := dist + (weight*factor).
  5218 
  5234 
  5219                 each -> (dist * weight)
  5235                 each -> (dist * weight)
  5220              ]
  5236              ]