eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'KeywordInContextIndexBuilder':

Home

everywhere
www.exept.de
for:
[back]

Class: KeywordInContextIndexBuilder


Inheritance:

   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)

Description:


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:]


Related information:



Examples:



    |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


ST/X 6.1.1; WebServer 1.620 at exept:8081; Mon, 21 May 2012 18:22:52 GMT