|
|
Class: KeywordInContextIndexBuilder
Object
|
+--KeywordInContextIndexBuilder
- Package:
- stx:libbasic2
- Category:
- Collections-Support
- Version:
- rev:
?
date: ? ?
- user: ?
- file: ? directory: libbasic2
- module: stx stc-classLibrary: libbasic2
- Author:
- Claus Gittinger (cg@alan)
A support class for building a KWIC (Keyword in Context) indices.
(for example, to build a KWIC index on html pages or class documentation).
[instance variables:]
[class variables:]
|kwic|
kwic := KeywordInContextIndexBuilder new.
kwic excluded:#('the' 'and' 'a' 'an').
kwic addLine:'bla bla bla' reference:1.
kwic addLine:'one two three' reference:2.
kwic addLine:'a cat and a dog' reference:3.
kwic addLine:'the man in the middle' reference:4.
kwic addLine:'the man with the dog' reference:5.
kwic
entriesDo:[:word :left :right :ref |
Transcript
show:((left contractTo:20) leftPaddedTo:20);
space;
show:((word contractTo:10) leftPaddedTo:10);
space;
show:((right contractTo:20) leftPaddedTo:20);
cr
].
|
KWIC index over method selector components:
|kwic|
kwic := KeywordInContextIndexBuilder new.
Smalltalk allClassesDo:[:eachClass |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
kwic addLine:sel reference:mthd.
]
].
kwic
|
KWIC index over method selector components, with word separation:
|kwic|
kwic := KeywordInContextIndexBuilder forMethodSelectorIndex.
Smalltalk allClassesDo:[:eachClass |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
kwic addLine:sel reference:mthd.
]
].
kwic
|
KWIC index over method comments:
|kwic|
kwic := KeywordInContextIndexBuilder forMethodComments.
Smalltalk allClassesDo:[:eachClass |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
|comment|
(sel == #documentation) ifTrue:[
comment := mthd comment.
comment notNil ifTrue:[
kwic addLine:comment reference:mthd mclass ignoreCase:true.
]
] ifFalse:[
(sel ~~ #examples
and:[ sel ~~ #copyright
and:[ sel ~~ #version]]) ifTrue:[
comment := mthd comment.
comment notNil ifTrue:[
kwic addLine:comment reference:mthd ignoreCase:true.
]
]
]
]
].
kwic
|
KWIC index over class comments:
|kwic|
kwic := KeywordInContextIndexBuilder forMethodComments.
Smalltalk allClassesDo:[:eachClass |
|mthd comment|
mthd := eachClass theMetaclass compiledMethodAt:#documentation.
mthd notNil ifTrue:[
comment := mthd comment.
comment notNil ifTrue:[
kwic addLine:comment reference:eachClass theNonMetaclass ignoreCase:true.
]
]
].
kwic
|
|