5223
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1375
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
|
14 |
"{ Package: 'stx:libbasic2' }"
|
|
15 |
|
4108
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
1375
|
18 |
Object subclass:#KeywordInContextIndexBuilder
|
4130
|
19 |
instanceVariableNames:'keywordToLinesMapping excluded separatorAlgorithm
|
4188
|
20 |
unquoteAlgorithm exclusionFilter matchSorter'
|
5223
|
21 |
classVariableNames:'FillWordsEnglish FillWordsGerman FillWordsFrench'
|
1375
|
22 |
poolDictionaries:''
|
|
23 |
category:'Collections-Support'
|
|
24 |
!
|
|
25 |
|
|
26 |
!KeywordInContextIndexBuilder class methodsFor:'documentation'!
|
|
27 |
|
|
28 |
copyright
|
|
29 |
"
|
|
30 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
31 |
All Rights Reserved
|
|
32 |
|
|
33 |
This software is furnished under a license and may be used
|
|
34 |
only in accordance with the terms of that license and with the
|
|
35 |
inclusion of the above copyright notice. This software may not
|
|
36 |
be provided or otherwise made available to, or used by, any
|
|
37 |
other person. No title to or ownership of the software is
|
|
38 |
hereby transferred.
|
|
39 |
"
|
|
40 |
!
|
|
41 |
|
|
42 |
documentation
|
|
43 |
"
|
4126
|
44 |
A support class for building KWIC (Keyword in Context) or KWOC (Keyword out of Context) indexes.
|
|
45 |
(for example, to build such indexes on html pages or class documentation).
|
4125
|
46 |
|
3184
|
47 |
To generate a kwic, add each line together with a reference (or page number, or whatever),
|
|
48 |
using addLine:reference:.
|
4126
|
49 |
Then, when finished, enumerate the kwic and print as kwic or kwoc.
|
4127
|
50 |
|
4187
|
51 |
To ignore fill words (such as 'and', 'the', 'in', etc.),
|
|
52 |
define those with the #excluded: messages.
|
|
53 |
|
|
54 |
The keyword handling is configurable by providing actions/lists for:
|
|
55 |
separatorAlgorithm a block which separates lines into individual words
|
|
56 |
gets a line; delivers a collection of words
|
|
57 |
|
|
58 |
excluded a collection of words which are to be ignored
|
|
59 |
|
|
60 |
unquoteAlgorithm a block to remove quotes around words.
|
|
61 |
gets word as argument, delivers unquoted word
|
|
62 |
|
|
63 |
keywordMappingAlgorithm
|
|
64 |
maps keywords; for example, can be used to map 'startsWith'
|
|
65 |
to 'start', so they appear in the same section.
|
|
66 |
Gets the word and the set-of-all-words as arguments,
|
|
67 |
delivers the key into which the word's entries should be placed
|
|
68 |
|
|
69 |
matchSorter determines the order in which keywords are listed
|
|
70 |
|
1375
|
71 |
[author:]
|
|
72 |
Claus Gittinger (cg@alan)
|
|
73 |
|
4126
|
74 |
[examples:]
|
|
75 |
see examples method
|
1375
|
76 |
|
|
77 |
[see also:]
|
4125
|
78 |
https://en.wikipedia.org/wiki/Key_Word_in_Context (english)
|
|
79 |
https://de.wikipedia.org/wiki/Permutiertes_Register (german)
|
|
80 |
|
1375
|
81 |
"
|
|
82 |
!
|
|
83 |
|
|
84 |
examples
|
|
85 |
"
|
4126
|
86 |
building a kwic; print as kwic and kwoc
|
1375
|
87 |
[exBegin]
|
|
88 |
|kwic|
|
|
89 |
|
|
90 |
kwic := KeywordInContextIndexBuilder new.
|
4127
|
91 |
kwic excluded:#('the' 'and' 'a' 'an' 'in').
|
1375
|
92 |
|
|
93 |
kwic addLine:'bla bla bla' reference:1.
|
4126
|
94 |
kwic addLine:'foo, bar. baz' reference:2.
|
|
95 |
kwic addLine:'one two three' reference:3.
|
|
96 |
kwic addLine:'a cat and a dog' reference:4.
|
|
97 |
kwic addLine:'the man in the middle' reference:5.
|
|
98 |
kwic addLine:'the man with the dog' reference:6.
|
1375
|
99 |
|
4126
|
100 |
Transcript showCR:'Printed as KWIC:'.
|
1375
|
101 |
kwic
|
|
102 |
entriesDo:[:word :left :right :ref |
|
|
103 |
Transcript
|
|
104 |
show:((left contractTo:20) leftPaddedTo:20);
|
|
105 |
space;
|
4124
|
106 |
show:((word contractTo:10) leftPaddedTo:10) allBold;
|
1375
|
107 |
space;
|
|
108 |
show:((right contractTo:20) leftPaddedTo:20);
|
2536
|
109 |
space;
|
|
110 |
show:'['; show:ref; show:']';
|
1375
|
111 |
cr
|
|
112 |
].
|
4126
|
113 |
|
|
114 |
Transcript cr.
|
|
115 |
Transcript showCR:'Printed as KWOC:'.
|
|
116 |
kwic
|
4128
|
117 |
entriesDo:[:word :left :right :ref :fullText :context |
|
4126
|
118 |
Transcript
|
|
119 |
show:((word contractTo:10) paddedTo:10) allBold;
|
|
120 |
space;
|
4128
|
121 |
show:((context contractTo:60) paddedTo:60);
|
4126
|
122 |
space;
|
|
123 |
show:'['; show:ref; show:']';
|
|
124 |
cr
|
|
125 |
].
|
1375
|
126 |
[exEnd]
|
|
127 |
|
|
128 |
|
3184
|
129 |
KWIC index over method selector components; build a little browser window:
|
1375
|
130 |
[exBegin]
|
3184
|
131 |
|kwic v s c list refs|
|
1375
|
132 |
|
|
133 |
kwic := KeywordInContextIndexBuilder new.
|
|
134 |
Smalltalk allClassesDo:[:eachClass |
|
|
135 |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
|
|
136 |
kwic addLine:sel reference:mthd.
|
|
137 |
]
|
|
138 |
].
|
3184
|
139 |
|
|
140 |
v := StandardSystemView new.
|
|
141 |
v addComponent:(s := HVScrollableView for:SelectionInListView).
|
|
142 |
s origin:0.0@0.0 corner:1.0@0.5.
|
|
143 |
v addComponent:(c := HVScrollableView for:CodeView).
|
|
144 |
c origin:0.0@0.5 corner:1.0@1.0.
|
|
145 |
|
|
146 |
refs := OrderedCollection new.
|
|
147 |
list := OrderedCollection new.
|
1375
|
148 |
kwic
|
3184
|
149 |
entriesDo:[:word :left :right :ref |
|
|
150 |
list add:(word,' ',left,' ',word allBold,' ',right,' (',ref mclass name,')').
|
|
151 |
refs add:ref].
|
|
152 |
s list:list.
|
|
153 |
s action:[:lNr | c contents:(refs at:lNr) source].
|
|
154 |
v open.
|
1375
|
155 |
[exEnd]
|
|
156 |
|
|
157 |
KWIC index over method selector components, with word separation:
|
|
158 |
[exBegin]
|
|
159 |
|kwic|
|
|
160 |
|
|
161 |
kwic := KeywordInContextIndexBuilder forMethodSelectorIndex.
|
|
162 |
|
|
163 |
Smalltalk allClassesDo:[:eachClass |
|
|
164 |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
|
|
165 |
kwic addLine:sel reference:mthd.
|
|
166 |
]
|
|
167 |
].
|
|
168 |
kwic
|
|
169 |
[exEnd]
|
|
170 |
|
|
171 |
KWIC index over method comments:
|
|
172 |
[exBegin]
|
4124
|
173 |
|kwic v s c refs list|
|
1375
|
174 |
|
|
175 |
kwic := KeywordInContextIndexBuilder forMethodComments.
|
|
176 |
|
|
177 |
Smalltalk allClassesDo:[:eachClass |
|
|
178 |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
|
|
179 |
|comment|
|
|
180 |
|
|
181 |
(sel == #documentation) ifTrue:[
|
|
182 |
comment := mthd comment.
|
|
183 |
comment notNil ifTrue:[
|
|
184 |
kwic addLine:comment reference:mthd mclass ignoreCase:true.
|
|
185 |
]
|
|
186 |
] ifFalse:[
|
|
187 |
(sel ~~ #examples
|
|
188 |
and:[ sel ~~ #copyright
|
|
189 |
and:[ sel ~~ #version]]) ifTrue:[
|
|
190 |
comment := mthd comment.
|
|
191 |
comment notNil ifTrue:[
|
|
192 |
kwic addLine:comment reference:mthd ignoreCase:true.
|
|
193 |
]
|
|
194 |
]
|
|
195 |
]
|
|
196 |
]
|
|
197 |
].
|
4124
|
198 |
kwic.
|
1375
|
199 |
[exEnd]
|
|
200 |
|
|
201 |
KWIC index over class comments:
|
|
202 |
[exBegin]
|
|
203 |
|kwic|
|
|
204 |
|
|
205 |
kwic := KeywordInContextIndexBuilder forMethodComments.
|
|
206 |
|
|
207 |
Smalltalk allClassesDo:[:eachClass |
|
|
208 |
|mthd comment|
|
|
209 |
|
|
210 |
mthd := eachClass theMetaclass compiledMethodAt:#documentation.
|
|
211 |
mthd notNil ifTrue:[
|
|
212 |
comment := mthd comment.
|
|
213 |
comment notNil ifTrue:[
|
|
214 |
kwic addLine:comment reference:eachClass theNonMetaclass ignoreCase:true.
|
|
215 |
]
|
|
216 |
]
|
|
217 |
].
|
|
218 |
kwic
|
|
219 |
[exEnd]
|
|
220 |
"
|
|
221 |
! !
|
|
222 |
|
|
223 |
!KeywordInContextIndexBuilder class methodsFor:'instance creation'!
|
|
224 |
|
|
225 |
forMethodComments
|
|
226 |
"return an indexer for method comments"
|
|
227 |
|
|
228 |
|sepChars sep kwic|
|
|
229 |
|
|
230 |
sepChars := '.,;:_ !![]()''"#?<>|' , Character return, Character lf, Character tab.
|
|
231 |
|
|
232 |
sep := [:lines | lines asString asCollectionOfSubstringsSeparatedByAny:sepChars].
|
|
233 |
|
|
234 |
kwic := self new.
|
|
235 |
kwic separatorAlgorithm:sep.
|
|
236 |
kwic excluded:#('the' 'and' 'a' 'an' 'for' 'with' 'no').
|
|
237 |
^ kwic
|
|
238 |
!
|
|
239 |
|
|
240 |
forMethodSelectorIndex
|
|
241 |
"return an indexer for method selector components, with word separation at case boundaries"
|
|
242 |
|
|
243 |
|sep kwic sepUCWords|
|
|
244 |
|
|
245 |
sepUCWords := [:word :keyWords|
|
|
246 |
|s w c lastC last2C frag|
|
|
247 |
|
|
248 |
word asLowercase = word ifTrue:[
|
|
249 |
keyWords add:word.
|
|
250 |
] ifFalse:[
|
|
251 |
s := word readStream.
|
|
252 |
w := '' writeStream.
|
|
253 |
[s atEnd] whileFalse:[
|
|
254 |
c := s next.
|
|
255 |
(c isUppercase) ifTrue:[
|
|
256 |
(lastC notNil and:[lastC isUppercase not]) ifTrue:[
|
|
257 |
keyWords add:w contents.
|
|
258 |
w := '' writeStream.
|
|
259 |
].
|
|
260 |
] ifFalse:[
|
|
261 |
(last2C notNil and:[last2C isUppercase and:[lastC isUppercase]]) ifTrue:[
|
|
262 |
c isLetter ifTrue:[
|
|
263 |
frag := w contents.
|
|
264 |
w := '' writeStream.
|
|
265 |
w nextPut:(frag last).
|
|
266 |
keyWords add:(frag allButLast).
|
|
267 |
] ifFalse:[
|
4108
|
268 |
"/ frag := w contents.
|
|
269 |
"/ w := '' writeStream.
|
|
270 |
"/ keyWords add:frag.
|
1375
|
271 |
].
|
|
272 |
].
|
|
273 |
].
|
|
274 |
w nextPut:c.
|
|
275 |
last2C := lastC.
|
|
276 |
lastC := c.
|
|
277 |
].
|
|
278 |
].
|
|
279 |
].
|
|
280 |
|
|
281 |
sep := [:line |
|
|
282 |
|words keyWords|
|
|
283 |
|
|
284 |
words := line asCollectionOfSubstringsSeparatedByAny:'.,;:_ '.
|
|
285 |
keyWords := OrderedCollection new.
|
|
286 |
words do:[:eachWord | sepUCWords value:eachWord value:keyWords].
|
|
287 |
keyWords
|
|
288 |
].
|
|
289 |
|
|
290 |
kwic := self new.
|
|
291 |
kwic separatorAlgorithm:sep.
|
|
292 |
^ kwic
|
|
293 |
!
|
|
294 |
|
|
295 |
new
|
|
296 |
^ self basicNew initialize
|
|
297 |
! !
|
|
298 |
|
5223
|
299 |
!KeywordInContextIndexBuilder class methodsFor:'queries'!
|
|
300 |
|
|
301 |
defaultFillWordsEnglish
|
|
302 |
^ #(
|
|
303 |
'the' 'a'
|
|
304 |
'can' 'you'
|
|
305 |
'to' 'in' 'out' 'at' 'of'
|
|
306 |
'also' 'with' 'without' 'all' 'any' 'how'
|
|
307 |
'however' 'although' 'always' 'either' 'neither'
|
|
308 |
'anywhere' 'anyway' 'anything' 'anyone'
|
|
309 |
'not' 'but' 'else' 'elsewhere'
|
|
310 |
'am' 'are' 'is' 'be' 'will' 'wont' 'won''t' 'do' 'don''t'
|
|
311 |
'no' 'non' 'now' 'old' 'on' 'only'
|
|
312 |
'my' 'their' 'your' 'its'
|
|
313 |
'one' 'two' 'three'
|
|
314 |
'etc' 'for' 'lot' 'lots' 'made' 'may' 'most' 'mostly' 'much'
|
|
315 |
'use' 'this' 'that' 'which' 'what' 'why'
|
|
316 |
'or' 'other' 'please'
|
5224
|
317 |
'vs' 'via'
|
5223
|
318 |
).
|
|
319 |
!
|
|
320 |
|
|
321 |
defaultFillWordsFrench
|
|
322 |
^ #(
|
|
323 |
'le' 'la' 'il' 'un' 'une'
|
|
324 |
).
|
|
325 |
!
|
|
326 |
|
|
327 |
defaultFillWordsGerman
|
|
328 |
^ #(
|
|
329 |
'der' 'die' 'das' 'ein' 'eine' 'einer' 'eines'
|
|
330 |
'kann' 'ich' 'du' 'er' 'sie' 'es' 'wir' 'ihr'
|
|
331 |
'zu' 'in' 'aus' 'bei' 'von'
|
|
332 |
'auch' 'mit' 'ohne' 'alle'
|
|
333 |
'wie' 'wo'
|
|
334 |
'jedoch' 'obgleich' 'immer' 'entweder' 'oder' 'weder' 'noch'
|
|
335 |
'irgendwo' 'dennoch' 'etwas' 'jemand'
|
|
336 |
'nicht' 'aber' 'ansonsten'
|
|
337 |
'bin' 'sind' 'ist' 'wird' 'nicht'
|
|
338 |
'nein' 'alt' 'auf' 'nur'
|
|
339 |
'mein' 'dein' 'sein'
|
|
340 |
'eins' 'zwei' 'drei'
|
|
341 |
'etc' 'kann'
|
|
342 |
'oder' 'bitte'
|
|
343 |
).
|
|
344 |
!
|
|
345 |
|
|
346 |
fillWordsEnglish
|
|
347 |
FillWordsEnglish isNil ifTrue:[
|
|
348 |
^ self defaultFillWordsEnglish
|
|
349 |
].
|
|
350 |
^ FillWordsEnglish
|
|
351 |
!
|
|
352 |
|
|
353 |
fillWordsFrench
|
|
354 |
FillWordsFrench isNil ifTrue:[
|
|
355 |
^ self defaultFillWordsFrench
|
|
356 |
].
|
|
357 |
^ FillWordsFrench
|
|
358 |
!
|
|
359 |
|
|
360 |
fillWordsGerman
|
|
361 |
FillWordsGerman isNil ifTrue:[
|
|
362 |
^ self defaultFillWordsGerman
|
|
363 |
].
|
|
364 |
^ FillWordsGerman
|
|
365 |
! !
|
|
366 |
|
1375
|
367 |
!KeywordInContextIndexBuilder methodsFor:'accessing'!
|
|
368 |
|
4128
|
369 |
excluded:aListOfExcludedWords
|
|
370 |
"define words which are to be ignored.
|
|
371 |
Typically, this is a list of fillwords, such as 'and', 'the', 'in', etc."
|
|
372 |
|
|
373 |
excluded := aListOfExcludedWords asSet.
|
1375
|
374 |
!
|
|
375 |
|
4130
|
376 |
exclusionFilter:aBlock
|
|
377 |
"define an additional filter to exclude more complicated patterns.
|
|
378 |
This is invoked after filtering by the exclusion list.
|
|
379 |
If defined, this should return true,if the word is to be excluded."
|
|
380 |
|
|
381 |
exclusionFilter := aBlock.
|
|
382 |
!
|
|
383 |
|
4132
|
384 |
matchSorter:aSortBlock
|
4187
|
385 |
"if set, matches will be enumerated in that sort order."
|
4132
|
386 |
|
|
387 |
matchSorter := aSortBlock.
|
|
388 |
!
|
|
389 |
|
4128
|
390 |
separatorAlgorithm:aBlock
|
|
391 |
"define the algorithm to split a given string into words.
|
|
392 |
The default is to split at punctuation and whitespace
|
|
393 |
(see #initialize)"
|
|
394 |
|
|
395 |
separatorAlgorithm := aBlock.
|
4130
|
396 |
!
|
|
397 |
|
|
398 |
unquoteAlgorithm:aBlock
|
|
399 |
"define the algorithm to unquote words.
|
|
400 |
The default is to unquote single and double quotes
|
|
401 |
(see #initialize)"
|
|
402 |
|
|
403 |
unquoteAlgorithm := aBlock.
|
1375
|
404 |
! !
|
|
405 |
|
|
406 |
!KeywordInContextIndexBuilder methodsFor:'building'!
|
|
407 |
|
|
408 |
addLine:aLine reference:opaqueReference
|
3184
|
409 |
"add a text line; the line is split at words and entered into the kwic.
|
4128
|
410 |
The reference argument is stored as 'value' of the generated entries.
|
|
411 |
It can be anything"
|
3184
|
412 |
|
4128
|
413 |
self addLine:aLine reference:opaqueReference ignoreCase:true
|
1375
|
414 |
!
|
|
415 |
|
|
416 |
addLine:aLine reference:opaqueReference ignoreCase:ignoreCase
|
4128
|
417 |
"add a line to the kwic.
|
|
418 |
The line is split up into words, and a reference to opaqueReference
|
|
419 |
is added for each word.
|
4188
|
420 |
The reference argument is stored as 'value' of the generated entries;
|
|
421 |
it can be anything"
|
4128
|
422 |
|
4187
|
423 |
(separatorAlgorithm value:aLine optionalArgument:keywordToLinesMapping) do:[:eachWord |
|
1375
|
424 |
|set word|
|
|
425 |
|
4131
|
426 |
(excluded includes:eachWord) ifFalse:[
|
|
427 |
word := unquoteAlgorithm value:eachWord.
|
|
428 |
ignoreCase ifTrue:[
|
|
429 |
word := word asLowercase.
|
|
430 |
].
|
|
431 |
(excluded includes:word) ifFalse:[
|
|
432 |
(exclusionFilter isNil or:[ (exclusionFilter value:word) not]) ifTrue:[
|
|
433 |
set := keywordToLinesMapping at:word ifAbsentPut:[Set new].
|
|
434 |
set add:(aLine -> opaqueReference).
|
|
435 |
]
|
4130
|
436 |
]
|
1375
|
437 |
]
|
|
438 |
].
|
4188
|
439 |
!
|
|
440 |
|
|
441 |
remapKeywordsWith:keywordMappingAlgorithm
|
|
442 |
"allows for an additional mapper to be applied (after the kwic has been constructed).
|
|
443 |
This can map multiple different words to the same keword.
|
|
444 |
It is given the word and the set of already known words as argument.
|
|
445 |
It may, for example figure out that a word with a long prefix is already in the
|
|
446 |
list and decide, that a new word should be brought into the same bucket.
|
|
447 |
For example, if 'starts' is already in the list, and 'startWith' is encountered."
|
|
448 |
|
|
449 |
|knownKeys|
|
4187
|
450 |
|
4188
|
451 |
knownKeys := keywordToLinesMapping keys copy.
|
|
452 |
knownKeys do:[:kw |
|
|
453 |
|mappedWord oldSet newSet|
|
|
454 |
|
|
455 |
mappedWord := keywordMappingAlgorithm value:kw optionalArgument:knownKeys.
|
|
456 |
mappedWord ~= kw ifTrue:[
|
|
457 |
oldSet := keywordToLinesMapping at:kw ifAbsent:[nil].
|
|
458 |
oldSet notNil ifTrue:[
|
|
459 |
newSet := keywordToLinesMapping at:mappedWord ifAbsentPut:[Set new].
|
|
460 |
oldSet do:[:eachEntry |
|
|
461 |
newSet add:eachEntry.
|
|
462 |
].
|
|
463 |
keywordToLinesMapping removeKey:kw.
|
4187
|
464 |
]
|
4188
|
465 |
]
|
4187
|
466 |
].
|
1375
|
467 |
! !
|
|
468 |
|
|
469 |
!KeywordInContextIndexBuilder methodsFor:'enumerating'!
|
|
470 |
|
4128
|
471 |
entriesDo:aFourToSixArgBlock
|
4126
|
472 |
"evaluate the argument, for each entry.
|
|
473 |
If it is a 4-arg block, it is called with:
|
|
474 |
kwic-word,
|
5224
|
475 |
left text,
|
4126
|
476 |
right text
|
|
477 |
and reference
|
|
478 |
If it is a 5-arg block, the original text is passed as additional argument.
|
4128
|
479 |
If it is a 6-arg block, the original text and the context are passed as additional argument.
|
4126
|
480 |
(stupid, but done for backward compatibility)"
|
3184
|
481 |
|
4128
|
482 |
|fourArgBlock|
|
4126
|
483 |
|
4128
|
484 |
aFourToSixArgBlock numArgs == 4 ifTrue:[
|
|
485 |
fourArgBlock := aFourToSixArgBlock
|
4126
|
486 |
].
|
1375
|
487 |
keywordToLinesMapping keys asSortedCollection do:[:eachKey |
|
|
488 |
|setOfMatches lcKey|
|
|
489 |
|
|
490 |
setOfMatches := keywordToLinesMapping at:eachKey.
|
4132
|
491 |
matchSorter notNil ifTrue:[
|
|
492 |
setOfMatches := setOfMatches asSortedCollection:matchSorter
|
|
493 |
].
|
1375
|
494 |
lcKey := eachKey asLowercase.
|
|
495 |
setOfMatches do:[:eachAssoc |
|
|
496 |
|text ref lines idx lIdx context left right word prevLine nextLine|
|
|
497 |
|
|
498 |
text := eachAssoc key.
|
|
499 |
ref := eachAssoc value.
|
|
500 |
|
|
501 |
lines := text asCollectionOfLines.
|
|
502 |
idx := lines findFirst:[:line | line asLowercase includesString:lcKey].
|
|
503 |
idx ~~ 0 ifTrue:[
|
|
504 |
context := lines at:idx.
|
|
505 |
idx > 1 ifTrue:[
|
|
506 |
prevLine := (lines at:idx-1).
|
|
507 |
context := prevLine , ' ' , context.
|
|
508 |
].
|
|
509 |
idx < lines size ifTrue:[
|
|
510 |
nextLine := (lines at:idx+1).
|
|
511 |
context := context , ' ' , nextLine.
|
|
512 |
].
|
|
513 |
lIdx := context asLowercase findString:lcKey.
|
|
514 |
left := (context copyTo:lIdx - 1) withoutSeparators.
|
|
515 |
right := (context copyFrom:lIdx + lcKey size) withoutSeparators.
|
|
516 |
word := (context copyFrom:lIdx to:lIdx + lcKey size - 1) withoutSeparators.
|
4126
|
517 |
fourArgBlock notNil ifTrue:[
|
|
518 |
fourArgBlock value:word value:left value:right value:ref.
|
|
519 |
] ifFalse:[
|
4128
|
520 |
aFourToSixArgBlock value:word optionalArgument:left and:right and:ref and:text and:context
|
4126
|
521 |
].
|
1375
|
522 |
].
|
|
523 |
]
|
|
524 |
]
|
|
525 |
! !
|
|
526 |
|
|
527 |
!KeywordInContextIndexBuilder methodsFor:'initialization'!
|
|
528 |
|
|
529 |
initialize
|
|
530 |
keywordToLinesMapping := Dictionary new.
|
4129
|
531 |
self excluded:(Set new).
|
4130
|
532 |
self exclusionFilter:nil.
|
4129
|
533 |
self separatorAlgorithm:[:line | line asCollectionOfSubstringsSeparatedByAny:' .:,;-'].
|
4130
|
534 |
self unquoteAlgorithm:[:word | (word unquote:$") unquote:$' ].
|
1375
|
535 |
! !
|
|
536 |
|
|
537 |
!KeywordInContextIndexBuilder class methodsFor:'documentation'!
|
|
538 |
|
|
539 |
version
|
4108
|
540 |
^ '$Header$'
|
2536
|
541 |
!
|
|
542 |
|
|
543 |
version_CVS
|
4108
|
544 |
^ '$Header$'
|
1375
|
545 |
! !
|
3184
|
546 |
|