eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'StringUtilities':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: StringUtilities


Inheritance:

   Object
   |
   +--StringUtilities

Package:
stx:libbasic2
Category:
Collections-Text-Support
Version:
rev: 1.9 date: 2019/05/30 09:26:50
user: cg
file: StringUtilities.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


some less often used algorithms have been moved to here to
make libbasic more compact.


Class protocol:

edit distance
o  editDistanceFrom: s1 to: s2 s: substWeight k: kbdTypoWeight c: caseWeight e: exchangeWeight i: insrtWeight
another, simpler editing distance between two strings.
See also: levenshtein

usage example(s):

     'comptuer' levenshteinTo:'computer'      
     self editDistanceFrom:'comptuer' to:'computer' s:4 k:2 c:1 e:nil i:2        

     'computr' levenshteinTo:'computer'                                    
     self editDistanceFrom:'computr' to:'computer' s:4 k:2 c:1 e:nil i:2        

o  isKey: k1 nextTo: k2
return true, if k1 and k2 are adjacent keys on the keyboard.
This is used to specially priorize plausible typing errors of adjacent keys.

usage example(s):

     self isKey:$a nextTo:$a   
     self isKey:$a nextTo:$s   
     self isKey:$a nextTo:$q   
     self isKey:$a nextTo:$w    
     self isKey:$a nextTo:$y    
     self isKey:$a nextTo:$z    
     self isKey:$a nextTo:$x    

o  isKey: k1 nextTo: k2 onKeyboard: keys
return true, if k1 and k2 are adjacent keys on the keyboard defined by keys

usage example(s):

     self isKey:$a nextTo:$q onKeyboard:(StringUtilities keyboardLayoutForLanguage:#de)
     self isKey:$a nextTo:$x onKeyboard:(StringUtilities keyboardLayoutForLanguage:#de)

o  keyboardLayout
the keyboard layout (used with algorithms to find possible typing errors,
for example: edit distance in levenshtein)

usage example(s):

     self keyboardLayout

o  keyboardLayoutForLanguage: lang
the keyboard layout (used with algorithms to find possible typing errors,
for example: edit distance in levenshtein).
CAVEAT: hard coded us- and german keyboards here - should go into resource file.

usage example(s):

     self keyboardLayoutForLanguage:#de 

o  levenshteinDistanceFrom: string1 to: string2 s: substWeight k: kbdTypoWeight c: caseWeight e: exchangeWeight i: insrtWeight d: deleteWeight
parametrized levenshtein.
return the levenshtein distance of two strings;
this value corrensponds to the number of replacements that have to be
made to get string2 from string1. The smaller the returned number,
tbe more similar are the two strings.

The arguments are the costs for
s:substitution,
k:keyboard type (substitution), if nil, s is used
c:case-change, if nil, s is used
i:insertion
d:deletion
e:exchange if nil, s*2 is used
of a character.
See IEEE transactions on Computers 1976 Pg 172 ff.

usage example(s):

     'comptuer' levenshteinTo:'computer'       

     self levenshteinDistanceFrom:'comptuer' to:'computer' 
            s:4 k:2 c:1 e:nil i:2 d:6    

matching
o  stringMatchFunctionFor: aMultiPattern glob: searchForGlobPattern regex: searchForRegexPattern caseSensitive: searchIsCaseSensitive
generates a check function which - given a string - checks for a match.
The match-pattern argument aMultiPattern
may contain multiple patterns,
separated by ';' (for and-search) or '|' (for or-search).
If the pattern is invalid, nil is returned and an information-notification
is signalled

queries
o  isUtilityClass



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 10 Aug 2022 10:23:02 GMT