@@ -1,4 +1,6 @@
11/- *sphinx
2+/+ sift
3+/+ m=metaphone
24|%
35++ iching
46 |= word=@t
@@ -10,7 +12,13 @@
1012 %+ turn
1113 (gulf 0 (sub (lent w) 3))
1214 |= index=@ud
13− (crip (swag [index 3] w))
15+ %- crip
16+ ^- tape
17+ ^- (list @)
18+ %+ sort
19+ `(list @ud)``(list @)`(swag [index 3] w)
20+ |= [p=@ud q=@ud]
21+ (gth q p)
1422++ digest
1523 |= =post
1624 ^- @uv
@@ -23,4 +31,109 @@
2331 description.post
2432 (crip tags.post)
2533 ==
34+++ derank
35+ |= [=entry offset=@ud]
36+ [hash.entry (add rank.entry offset)] :: phonetically similar should be lower
37+++ sort-entries
38+ |= entries=(list entry)
39+ %+ sort entries
40+ |= [a=entry b=entry]
41+ (lth rank.a rank.b)
42+++ get-hashes
43+ |= entries=(list entry)
44+ %+ turn
45+ entries
46+ |=(=entry hash.entry)
47+++ delver
48+ |_ [=lookup =trigrams =phonetics]
49+ ++ get-entries
50+ |= =key
51+ ^- (list entry)
52+ =/ title (norm:sift key) :: full query
53+ =/ parts (sift:sift key) :: split query
54+ =/ title-entries
55+ %- malt
56+ ;: weld
57+ (get-phonetics title)
58+ (get-trigram-entries title)
59+ (~(gut by lookup) title *(list entry))
60+ ==
61+ %~ tap by
62+ %-
63+ %~ uni by :: union and prefer title entries (better rank)
64+ %- malt
65+ %- zing
66+ %+ turn
67+ parts
68+ |= word=@t
69+ %+ turn
70+ ;: weld
71+ (get-phonetics word)
72+ (get-trigram-entries word)
73+ (~(gut by lookup) word *(list entry))
74+ ==
75+ |= =entry
76+ (derank entry 10)
77+ title-entries
78+ ++ get-trigram-entries
79+ |= term=@t
80+ ^- (list entry)
81+ %- zing
82+ %+ turn
83+ (get-keys term)
84+ |= item=@t
85+ (~(gut by lookup) item *(list entry))
86+ ++ get-phonetics
87+ |= term=key
88+ ^- (list entry)
89+ =/ keys
90+ %+ skim
91+ %~ tap in
92+ (~(gut by phonetics) (utter:m term) *(set key))
93+ |= [word=key]
94+ !=(term word)
95+ %+ roll
96+ keys
97+ |= [word=key entries=(list entry)]
98+ %+ weld
99+ entries
100+ %+ turn
101+ (~(gut by lookup) word *(list entry))
102+ |= =entry
103+ (derank entry 10)
104+ ++ get-keys
105+ |= term=@t
106+ ^- (list @t)
107+ =/ tally (get-term-counts term)
108+ ~& tally
109+ =/ tallys ~(tap by tally)
110+ =/ count (lent (iching term))
111+ %+ turn
112+ %+ sort
113+ %+ skim
114+ tallys
115+ |= [k=@t v=@ud]
116+ (gth:rs (div:rs (sun:rs v) (sun:rs count)) .0.6)
117+ |= [[k=@t v=@ud] [l=@t w=@ud]]
118+ (lth v w)
119+ |= [k=@t v=@ud]
120+ k
121+ ++ get-term-counts
122+ |= term=@t
123+ ^- (map @t @ud)
124+ %+ roll
125+ (iching term)
126+ |= [ngram=@t tally=(map @t @ud)]
127+ ^- (map @t @ud)
128+ =/ words=(set @t) (~(gut by trigrams) ngram *(set @t))
129+ %-
130+ %- ~(uno by tally)
131+ %- malt
132+ %+ turn
133+ ~(tap in words)
134+ |= word=@t
135+ [word 1]
136+ |= [k=@t v=@ud w=@ud]
137+ (add v w)
138+ --
26139--