blob: d01fb76d8325835e365b3e26a2be9d1f531cd4d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
@(next :args)
@
@
@
@(deffilter remdbl ("AA" "A") ("BB" "B") ("CC" "C") ("DD" "D") ("EE" "E")
("FF" "F") ("GG" "G") ("HH" "H") ("II" "I") ("JJ" "J")
("KK" "K") ("LL" "L") ("MM" "M") ("NN" "N") ("OO" "O")
("PP" "P") ("QQ" "Q") ("RR" "R") ("SS" "S") ("TT" "T")
("UU" "U") ("VV" "V") ("WW" "W") ("XX" "X") ("YY" "Y")
("ZZ" "Z"))
@(deffilter code ("B" "F" "P" "V" "1")
("C" "G" "J" "K" "Q" "S" "X" "Z" "2")
("D" "T" "3") ("L" "4") ("M" "N" "5")
("R" "6") ("A" "E" "I" "O" "U" "Y" "0") ("H" "W" ""))
@(deffilter squeeze ("11" "111" "1111" "11111" "1")
("22" "222" "2222" "22222" "2")
("33" "333" "3333" "33333" "3")
("44" "444" "4444" "44444" "4")
("55" "555" "5555" "55555" "5")
("66" "666" "6666" "66666" "6"))
@(bind prefix ("VAN" "CON" "DE" "DI" "LA" "LE"))
@(deffilter remzero ("0" ""))
@
@
@
@(define soundex (in out))
@ (local nodouble letters remainder first rest coded)
@ (next :string in)
@ (coll :vars (letters))@{letters /[A-Za-z]+/}@(end)
@ (cat letters)
@ (output :into nodouble :filter (:upcase remdbl))
@letters
@ (end)
@ (next :list nodouble)
@ (maybe)
@prefix@remainder
@ (output :into nodouble)
@nodouble
@remainder
@ (end)
@ (end)
@ (next :list nodouble)
@ (collect)
@{first 1}@rest
@ (output :filter (code squeeze remzero) :into coded)
@{rest}000
@ (end)
@ (next :list coded)
@{digits 3}@(skip)
@ (end)
@ (output :into out)
@ (rep):@first@digits@(first)@first@digits@(end)
@ (end)
@ (cat out)
@(end)
@
@
@
@(collect :vars ())
@input
@ (output :filter (:fun soundex))
@input
@ (end)
@(end)
@
@
@
@(bind (first_arg second_arg . rest) input)
@(cases)
@ (bind first_arg second_arg :filter (:fun soundex))
@ (output)
"@first_arg" and "@second_arg" match under soundex
@ (end)
@(or)
@ (output)
"@first_arg" and "@second_arg" do not match under soundex
@ (end)
@(end)
|