extensions.st
changeset 2199 a9d3b1aa9f03
parent 2150 bdd3b90b3dae
child 2237 3b041af2bf04
equal deleted inserted replaced
2198:c2363f48b40b 2199:a9d3b1aa9f03
     1 "{ Package: 'stx:libbasic2' }"
     1 "{ Package: 'stx:libbasic2' }"
     2 !
     2 !
       
     3 
       
     4 !CharacterArray methodsFor:'converting'!
       
     5 
       
     6 asKoelnerPhoneticCode
       
     7     "return a koelner phonetic code.
       
     8      The koelnerPhonetic code is for the german language what the soundex code is for english;
       
     9      it returns simular strings for similar sounding words. 
       
    10      There are some differences to soundex, though: 
       
    11         its length is not limited to 4, but depends on the length of the original string;
       
    12         it does not start with the first character of the input."
       
    13 
       
    14     ^ PhoneticStringUtilities koelnerPhoneticCodeOf:self 
       
    15 
       
    16     "
       
    17      #(
       
    18         'Müller'
       
    19         'Miller'
       
    20         'Mueller'
       
    21         'Mühler'
       
    22         'Mühlherr'
       
    23         'Mülherr'
       
    24         'Myler'
       
    25         'Millar'
       
    26         'Myller'
       
    27         'Müllar'
       
    28         'Müler'
       
    29         'Muehler'
       
    30         'Mülller'
       
    31         'Müllerr'
       
    32         'Muehlherr'
       
    33         'Muellar'
       
    34         'Mueler'
       
    35         'Mülleer'
       
    36         'Mueller'
       
    37         'Nüller'
       
    38         'Nyller'
       
    39         'Niler'
       
    40         'Czerny'
       
    41         'Tscherny'
       
    42         'Czernie'
       
    43         'Tschernie'
       
    44         'Schernie'
       
    45         'Scherny'
       
    46         'Scherno'
       
    47         'Czerne'
       
    48         'Zerny'
       
    49         'Tzernie'
       
    50         'Breschnew'
       
    51      ) do:[:w |
       
    52          Transcript show:w; show:'->'; showCR:(w asKoelnerPhoneticCode)
       
    53      ].
       
    54     "
       
    55 
       
    56     "
       
    57      'Breschnew' asKoelnerPhoneticCode -> '17863'
       
    58      'Breschnew' asKoelnerPhoneticCode -> '17863'
       
    59      'Breschneff' asKoelnerPhoneticCode -> '17863'
       
    60      'Braeschneff' asKoelnerPhoneticCode -> '17863'
       
    61      'Braessneff' asKoelnerPhoneticCode -> '17863'
       
    62      'Pressneff' asKoelnerPhoneticCode -> '17863'
       
    63      'Presznäph' asKoelnerPhoneticCode -> '17863'
       
    64     "
       
    65 ! !
       
    66 
       
    67 !CharacterArray methodsFor:'converting'!
       
    68 
       
    69 asSoundexCode
       
    70     "return a soundex phonetic code or nil.
       
    71      Soundex returns similar codes for similar sounding words, making it a useful
       
    72      tool when searching for words where the correct spelling is unknown.
       
    73      (read Knuth or search the web if you dont know what a soundex code is).
       
    74      Caveat: 'similar sounding words' means: 'similar sounding in english'."
       
    75 
       
    76     ^ PhoneticStringUtilities soundexCodeOf:self
       
    77 
       
    78     "
       
    79      'claus' asSoundexCode     
       
    80      'clause' asSoundexCode
       
    81      'close' asSoundexCode
       
    82      'smalltalk' asSoundexCode
       
    83      'smaltalk' asSoundexCode
       
    84      'smaltak' asSoundexCode
       
    85      'smaltok' asSoundexCode
       
    86      'smoltok' asSoundexCode
       
    87      'aa' asSoundexCode
       
    88      'by' asSoundexCode
       
    89      'bab' asSoundexCode
       
    90      'bob' asSoundexCode
       
    91      'bop' asSoundexCode
       
    92     "
       
    93 ! !
     3 
    94 
     4 !Object methodsFor:'dependents-interests'!
    95 !Object methodsFor:'dependents-interests'!
     5 
    96 
     6 addInterest:anInterest
    97 addInterest:anInterest
     7     "install an interest forwarder.
    98     "install an interest forwarder.