FuzzyMatcher.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Jun 2019 14:28:51 +0200
changeset 5050 44fa8672d102
parent 4493 3961346f8256
child 5376 61b8a719febd
permissions -rw-r--r--
#DOCUMENTATION by cg class: SharedQueue comment/format in: #next #nextWithTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:libbasic2' }"
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: Smalltalk }"
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
Object subclass:#FuzzyMatcher
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:'pattern lowercasePattern indexes'
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	category:'Collections-Text-Support'
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!FuzzyMatcher class methodsFor:'documentation'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
documentation
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
"
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
    16
    FuzzyMatcher is an approximate string matching algorithm that can determine if a string includes a given pattern.
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
    For example, the string 'axby' matches both the pattern 'ab' and, 'ay', but not 'ba'. 
4492
05def04efc34 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
    18
    I.e. it matches if the searched string contains a sequence of chars, probably intermixed by other chars,
05def04efc34 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
    19
    which matches the given search pattern or part of it.
05def04efc34 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
    20
    
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    The algorithm is based on lib_fts[1], and includes an optional scoring algorithm 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
    that can be used to sort all the matches based on their similarity to the pattern.
4492
05def04efc34 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4477
diff changeset
    23
    It is used (among others) in the sublime text editor.
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    24
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    25
    [caveat:]
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    26
        although this works great for class searches,
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    27
        it is strange that 'dabc' scores lower against 'abc' than 'adbc'
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    28
        (dabc has a longer common subsequence without interruptions...)
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    29
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
    [see also:]
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
        https://blog.forrestthewoods.com/reverse-engineering-sublime-text-s-fuzzy-match-4cffeed33fdb
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
        https://github.com/forrestthewoods/lib_fts
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
4468
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    35
!
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    36
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    37
example
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    38
"
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    39
    |matcher|
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    40
    
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    41
    matcher := FuzzyMatcher pattern:'abc'.
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    42
    matcher 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    43
        match:'somearbitrarysequence'   
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    44
        ifScored: [:score | Transcript show:('''somearbitrarysequence'' scores '); showCR:score].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    45
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    46
    matcher 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    47
        match:'someabcd'   
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    48
        ifScored: [:score | Transcript show:('''someabcd'' scores '); showCR:score].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    49
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    50
    matcher 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    51
        match:'abcd'   
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    52
        ifScored: [:score | Transcript show:('''abcd'' scores '); showCR:score].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    53
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    54
    matcher 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    55
        match:'dabc'   
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    56
        ifScored: [:score | Transcript show:('''dabc'' scores '); showCR:score].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    57
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    58
    matcher 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    59
        match:'adbc'   
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    60
        ifScored: [:score | Transcript show:('''adbc'' scores '); showCR:score].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    61
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    62
    matcher 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    63
        match:'abc'   
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    64
        ifScored: [:score | Transcript show:('''abc'' scores '); showCR:score].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    65
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
    66
    
4468
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    67
    |top lv list field patternHolder names|
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    68
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    69
    patternHolder := '' asValue.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    70
    list := List new.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    71
    
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    72
    top := StandardSystemView new.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    73
    lv := ListView origin:(0.0@30) corner:(1.0@1.0) in:top.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    74
    lv model:list.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    75
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    76
    field := EditField origin:(0.0@0.0) corner:(1.0@30) in:top.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    77
    field model:patternHolder.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    78
    field immediateAccept:true.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    79
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    80
    names := Smalltalk allClasses collect:#name.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    81
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    82
    patternHolder 
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    83
        onChangeEvaluate:[
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    84
            |matcher pattern matches|
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    85
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    86
            pattern := patternHolder value.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    87
            pattern notEmpty ifTrue:[
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    88
                matcher := FuzzyMatcher pattern:pattern.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    89
                
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    90
                matches := OrderedCollection new.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    91
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    92
                names do:[:eachClassName | 
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    93
                    matcher 
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    94
                        match:eachClassName
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    95
                        ifScored: [ :score | matches add: eachClassName -> score ] 
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
    96
                ].
4470
5825ccc0dabf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4469
diff changeset
    97
                matches sort:[:a :b |
5825ccc0dabf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4469
diff changeset
    98
                        a value < b value
5825ccc0dabf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4469
diff changeset
    99
                        or:[ a value = b value and:[ a key > b key]]
5825ccc0dabf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4469
diff changeset
   100
                ].
4468
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   101
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   102
                list removeAll.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   103
                list addAllReversed:(matches 
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   104
                                collect:[:nameScoreAssoc | 
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   105
                                    '[%1] %2' bindWith:nameScoreAssoc value with:nameScoreAssoc key])
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   106
            ].    
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   107
        ].    
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   108
    top open.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   109
    patternHolder value:'mph'.
4da827f70608 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4459
diff changeset
   110
"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
!FuzzyMatcher class methodsFor:'instance creation'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
new
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    "return an initialized instance"
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    ^ self basicNew initialize.
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   119
!
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
pattern: aString
4476
65686f14ebf4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4475
diff changeset
   122
    ^ self new pattern: aString
65686f14ebf4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4475
diff changeset
   123
65686f14ebf4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4475
diff changeset
   124
    "
65686f14ebf4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4475
diff changeset
   125
     (self pattern:'mrp') matches:'ButtonMorph'
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   126
     (self pattern:'mrp') matches:'ButtonMorh'
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   127
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   128
     (self pattern:'mrp') matches:'ButtonMorph'
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   129
     (self pattern:'mrp') matches:'ButtonMorh'
4476
65686f14ebf4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4475
diff changeset
   130
    "
65686f14ebf4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4475
diff changeset
   131
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   132
    "Modified (comment): / 02-08-2017 / 15:57:07 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
!FuzzyMatcher class methodsFor:'utilities api'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
allMatching: aPattern in: aCollection
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   138
    "Assumes that the collection is a collection of Strings;
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   139
     return all those which match"
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   140
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   141
    | matcher |
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   143
    matcher := self pattern: aPattern.
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   144
    ^ aCollection select: [ :each | matcher matches: each ]
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   146
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   147
     self 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   148
        allMatching:'clu' 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   149
        in:(Smalltalk allClasses collect:#name)
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   150
    "
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   152
    "Modified (comment): / 02-08-2017 / 16:02:44 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
allMatching: aPattern in: aCollection by: aBlockReturningString
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   156
    "selects matching elements from aCollection.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   157
     aBlockReturningString is applied to elements to get the string representation
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   158
     (can be used eg. to sort classes)"
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   159
     
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   160
    | matcher |
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   161
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   162
    matcher := self pattern: aPattern.
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   163
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   164
    ^ aCollection select: [ :each | matcher matches: (aBlockReturningString value: each) ]
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   166
        "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   167
         self 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   168
            allMatching:'clu' 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   169
            in:(Smalltalk allClasses)
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   170
            by:[:cls | cls name]
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   171
        "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   172
        "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   173
         self 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   174
            allMatching:'clu' 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   175
            in:(Smalltalk allClasses)
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   176
            by:#name
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   177
        "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   178
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   179
    "Modified (comment): / 14-07-2017 / 12:21:40 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
allSortedByScoreMatching: aPattern in: aCollection
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   183
    "Assumes that the collection is a collection of Strings;
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   184
     returns matching strings sorted by score (level of similarity)"
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   185
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   186
    ^ self allSortedByScoreMatching: aPattern in: aCollection by: [ :each | each ]
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   187
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   188
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   189
     self 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   190
        allSortedByScoreMatching:'clu' 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   191
        in:(Smalltalk allClasses collect:#name)
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   192
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   193
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   194
     self 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   195
        allSortedByScoreMatching:'nary' 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   196
        in:(Smalltalk allClasses collect:#name)
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   197
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   198
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   199
    "Modified (comment): / 14-07-2017 / 12:22:14 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
allSortedByScoreMatching: aPattern in: aCollection by: aBlockReturningString
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   203
    "selects matching elements from aCollection.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   204
     aBlockReturningString is applied to elements to get the string representation.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   205
     Returns them sorted by score (i.e. similarity).
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   206
     (can be used eg. to sort classes)"
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   207
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   208
    | matchesAndScores |
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   209
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   210
    matchesAndScores := self allWithScoresSortedByScoreMatching: aPattern in: aCollection by: aBlockReturningString.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   211
    ^ matchesAndScores collect: [ :each | each value ]
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   212
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   213
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   214
     self 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   215
        allSortedByScoreMatching:'' 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   216
        in:(Smalltalk allClasses)
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   217
        by:[:cls | cls name]
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   218
    "
4474
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   219
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   220
     self 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   221
        allSortedByScoreMatching:'nary' 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   222
        in:(Smalltalk allClasses)
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   223
        by:[:cls | cls name]
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   224
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   225
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   226
     self 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   227
        allSortedByScoreMatching:'nary' 
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   228
        in:(Smalltalk allClasses)
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   229
        by:#name
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   230
    "
98208d107b52 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4470
diff changeset
   231
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   232
    "Modified: / 14-07-2017 / 12:43:14 / cg"
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   233
!
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   234
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   235
allWithScoresSortedByScoreMatching: aPattern in: aCollection by: aBlockReturningString
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   236
    "selects matching elements from aCollection.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   237
     aBlockReturningString is applied to elements to get the string representation.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   238
     Returns them sorted by score (i.e. similarity) associated to their scores.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   239
     (can be used eg. to sort classes)"
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   240
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   241
    |matcher matches|
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   242
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   243
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   244
    matcher := self pattern: aPattern.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   245
    matches := OrderedCollection new: aCollection size // 2.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   246
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   247
    aCollection do: [ :each | 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   248
        matcher 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   249
            match: (aBlockReturningString value: each) 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   250
            ifScored: [ :score | matches add: score -> each ] 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   251
    ].
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   252
    matches sort: [ :a :b | a key > b key].
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   253
    ^ matches asArray
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   254
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   255
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   256
     self 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   257
        allWithScoresSortedByScoreMatching:'' 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   258
        in:(Smalltalk allClasses)
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   259
        by:[:cls | cls name]
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   260
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   261
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   262
     self 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   263
        allWithScoresSortedByScoreMatching:'OC' 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   264
        in:(Smalltalk allClasses)
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   265
        by:[:cls | cls name]
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   266
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   267
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   268
     self 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   269
        allWithScoresSortedByScoreMatching:'nary' 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   270
        in:(Smalltalk allClasses)
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   271
        by:[:cls | cls name]
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   272
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   273
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   274
     self 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   275
        allWithScoresSortedByScoreMatching:'nary' 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   276
        in:(Smalltalk allClasses)
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   277
        by:#name
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   278
    "
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   279
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   280
    "Created: / 14-07-2017 / 12:25:19 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
!FuzzyMatcher methodsFor:'accessing'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
4477
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   285
indexes
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   286
    "only valid inside the match callback block"
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   287
    
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   288
    ^ indexes
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   289
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   290
    "Created: / 15-07-2017 / 14:57:10 / cg"
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   291
!
99941fe21a09 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4476
diff changeset
   292
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
pattern
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
	^ pattern 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
pattern: aString
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   300
        pattern := aString.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   301
        lowercasePattern := pattern asLowercase.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   302
        indexes := Array new: pattern size.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   303
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   304
    "Modified (format): / 14-07-2017 / 12:59:15 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   307
!FuzzyMatcher methodsFor:'api - comparing'!
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
match: aString ifScored: aBlock
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   310
    "If there is a match, evaluate aBlock, passing the score value"
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   311
        
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   312
    | scoreOrNil |
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   313
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   314
    scoreOrNil := self matchScoreOrNil: aString.
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   315
    scoreOrNil notNil ifTrue:[
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   316
        aBlock value:scoreOrNil
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   317
    ].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   318
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   319
    "Modified: / 02-08-2017 / 16:00:59 / cg"
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   320
!
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   321
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   322
matchScoreOrNil: aString
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   323
    "return the scrore if there is a match; nil otherwise."
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   324
        
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   325
    | score |
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   326
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   327
    pattern ifEmpty: [ ^ (aString size negated) ].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   328
    (self matches: aString) ifFalse: [ ^ nil ].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   329
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   330
    score := self firstScore: aString at: indexes first.
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   331
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   332
    2 to: pattern size do: [ :pix | 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   333
            score := score + (self score: aString at: (indexes at: pix) patternAt: pix)
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   334
    ].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   335
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   336
    score := score + self indexScore + ((aString size - pattern size) * self unmatchedLetterPenalty).
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   337
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   338
    ^ score.
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   339
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   340
    "Created: / 02-08-2017 / 15:59:56 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
matches: aString
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   344
    "return true if there is a match; false otherwise."
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   345
     
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   346
    | idx |
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   348
    pattern size > aString size ifTrue: [ ^ false ].
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   350
    idx := 0.
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   351
    pattern withIndexDo: [ :each :i |
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   352
            idx := aString 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   353
                    findString: each asString 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   354
                    startingAt: idx + 1 
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   355
                    caseSensitive: false. 
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
4493
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   357
            idx == 0 ifTrue: [ ^ false ].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   358
            indexes at: i put: idx.
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   359
    ].
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   360
    ^ true
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   361
3961346f8256 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
   362
    "Modified (format): / 02-08-2017 / 16:01:05 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
!FuzzyMatcher methodsFor:'initialization'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
initialize
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   369
        super initialize.
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   371
        pattern := lowercasePattern := ''.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   372
        indexes := #().
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   373
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   374
    "Modified (format): / 14-07-2017 / 13:23:26 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
!FuzzyMatcher methodsFor:'private'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
firstScore: aString at: anIndex
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
	| score |
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
	score := (aString at: anIndex) = pattern first 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
		ifTrue: [ self caseEqualBonus ]
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
		ifFalse: [ 0 ].
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
	
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
	anIndex = 1 	ifTrue: [ ^ score + self firstLetterBonus ].
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
		
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
	score := score + (((anIndex - 1) * self leadingLetterPenalty) max: self maxLeadingLetterPenalty).
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
				
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
	^ score 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
indexScore 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
4475
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   396
        | sum ramp |
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   397
        
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   398
        ramp := 1.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   399
        sum := 0.
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   400
        
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   401
        1 to: indexes size - 1 do: [ :ix |
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   402
                ramp := (indexes at: ix) + 1 = (indexes at: ix + 1) 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   403
                        ifTrue: [ ramp + (ramp * self adjacencyIncrease) ]
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   404
                        ifFalse: [ 1 ].                 
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   405
                
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   406
                sum := sum + ramp - 1
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   407
        ].
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   408
        
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   409
        ^ sum rounded
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   410
2e19c5a7452a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4474
diff changeset
   411
    "Modified (format): / 14-07-2017 / 13:24:07 / cg"
4459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
isSeparator: aCharacter
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
        
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
        ^  aCharacter = $_ or: [ aCharacter = $: ]
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
    "Created: / 13-07-2017 / 13:30:34 / cg"
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
score: aString at: stringIndex patternAt: patternIndex
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
        | score prev |
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
        
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
        prev := (aString at: stringIndex - 1).
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
        
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
        score := (self isSeparator: prev) 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
                ifTrue: [ self separatorBonus ]
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
                ifFalse: [ (prev asLowercase = (lowercasePattern at: patternIndex - 1))
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
                        ifTrue: [ 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
                                self adjacencyBonus + 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
                                ((prev = (pattern at: patternIndex - 1)) ifTrue: [ self adjacentCaseEqualBonus ] ifFalse: [ 0 ]) 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
                        ] 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
                        ifFalse: [ 0 ] 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
                ].
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
        
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
        (aString at: stringIndex) = (pattern at: patternIndex) ifTrue: [ 
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
                score := score + self caseEqualBonus.
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
        ].
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
        ^ score
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
    "Modified: / 13-07-2017 / 13:30:57 / cg"
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
!FuzzyMatcher methodsFor:'scoring-bonus'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
adjacencyBonus
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
	^ 5
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
adjacencyIncrease
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
	^ 1.2
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
adjacentCaseEqualBonus
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
	^ 3
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
caseEqualBonus
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
	^ 7
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
firstLetterBonus
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
	^ 12
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
separatorBonus
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
	^ 5
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
!FuzzyMatcher methodsFor:'scoring-penalty'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
leadingLetterPenalty
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
	^ -3
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
maxLeadingLetterPenalty
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
	^ -9
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
unmatchedLetterPenalty
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
	^ -1
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
!FuzzyMatcher class methodsFor:'documentation'!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
version
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
    ^ '$Header$'
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
!
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
version_CVS
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    ^ '$Header$'
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
! !
cfbde361fe34 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504