43 lines
1.4 KiB
Mathematica
43 lines
1.4 KiB
Mathematica
XTLKWIC ;IHS/OHPRD/ACC,ALB/JLU,SFISC/JC - KWIC ROUTINE FOR FILE MANAGER ;07/22/93 15:52
|
|
;;7.3;TOOLKIT;;Apr 25, 1995
|
|
S N SWB,OSTATE,STATE,LLEN,C,D,I,J,WF,WS,WD,WD2,WL,END,Q
|
|
S D=%,L=$S($D(JLX):JLX,1:X) K JLX
|
|
D TOKENIZE S I="" F J=0:0 S I=$O(WT(I)) Q:I="" I ^DD("KWIC")'[("^"_I_"^") S @D=""
|
|
G QUIT
|
|
K N SWB,OSTATE,STATE,LLEN,C,D,I,J,WF,WS,WD,WD2,WL,END,Q
|
|
S D=%,L=$S($D(JLX):JLX,1:X) K JLX
|
|
D TOKENIZE S I="" F J=0:0 S I=$O(WT(I)) Q:I="" I ^DD("KWIC")'[("^"_I_"^") K:'($D(@D)\10) @D
|
|
QUIT K WT,I,J Q
|
|
TOKENIZE ; CONVERT INPUT LINE TO TOKENS ; [ 03/20/86 12:44 PM ]
|
|
K WT
|
|
D CONVERT
|
|
K SWB,OSTATE,STATE,LLEN,C,I,J,WF,WS,WD,WD2,WL,END,Q
|
|
Q
|
|
;
|
|
CONVERT ; DO ACTUAL CONVERSION
|
|
S SWB="",STATE="SKIP",I=0,LLEN=$L(L)
|
|
CHLOOP S I=I+1
|
|
I I>LLEN S END=1 D:STATE="SCAN" ENDWORD Q
|
|
S C=$E(L,I)
|
|
S OSTATE=STATE
|
|
I OSTATE="SKIP",C'?1P S STATE="SCAN",WS=I
|
|
I OSTATE="SCAN",C?1P,C'="-",C'="'" S END=0 D ENDWORD S STATE="SKIP"
|
|
G CHLOOP
|
|
ENDWORD S WL=I-WS,WD=$E(L,WS,I-1)
|
|
I WL=1 S SWB=SWB_WD I END S WD=SWB D STOREWD
|
|
I WL>1 D STOREWD I SWB'="" S WD=SWB,SWB="" D STOREWD
|
|
Q
|
|
STOREWD ;
|
|
REMQT S J=$F(WD,"'") I J>0 S WD=$E(WD,1,J-2)_$E(WD,J,255) G REMQT
|
|
I WD'["-" D STOREWD2 Q
|
|
S WD2="" F J=1:1 S WF=$P(WD,"-",J) Q:WF="" Q:$L(WF)>2 S WD2=WD2_WF
|
|
I WF="" S WD=WD2 D STOREWD2 Q
|
|
S WD2=WD F J=1:1 S WF=$P(WD2,"-",J) Q:WF="" S WD=WF D STOREWD2
|
|
Q
|
|
STOREWD2 ;
|
|
Q:(WD?1N.E)!(^DD("KWIC")[("^"_WD_"^"))
|
|
Q:$L(WD)=2&("^IN^OF^AN^IS^AS^AT^IF^IT^ON^OR^BY^"[("^"_WD_"^"))
|
|
Q:WD?1N.E
|
|
S WT(WD)=""
|
|
Q
|