LEXERF ;ISL/KER - Functions for Exc/Rep Words ;04/21/2014
;;2.0;LEXICON UTILITY;**80**;Sep 23, 1996;Build 1
;
; Global Variables
; ^TMP("LEXTKN") SACC 2.3.2.5.1
;
; External References
; $$UP^XLFSTR ICR 10103
;
EXIST(X) ; Boolean function returns:
; 0 If X will result in a unsuccessful search (not found)
; 1 If X will result in a successful search (found)
; IFN If X has an exact match (found)
Q:'$D(X) 0 Q:X="" 0
I $D(^LEX(757.01,"AB",$$UP^XLFSTR(X))) Q $O(^LEX(757.01,"AB",$$UP^XLFSTR(X),0))
N LEXOK D PTX^LEXTOKN S LEXOK=1
I '$D(^TMP("LEXTKN",$J,0)) K ^TMP("LEXTKN"),LEXOK Q 0
I ^TMP("LEXTKN",$J,0)<1 K ^TMP("LEXTKN"),LEXOK Q 0
I ^TMP("LEXTKN",$J,0)=1 D K ^TMP("LEXTKN"),LEXKEY,LEXKEY2 Q LEXOK
. S LEXKEY=$O(^TMP("LEXTKN",$J,1,""))
. S:$L(LEXKEY)>1 LEXKEY2=$E(LEXKEY,1,$L(LEXKEY)-1)_$C($A($E(LEXKEY,$L(LEXKEY)))-1)_"~"
. S:$L(LEXKEY)=1 LEXKEY2=$C($A(LEXKEY)-1)_"~"
. S:$G(LEXKEY2)="" LEXKEY2=""
. S:LEXKEY="" LEXOK=0 Q:LEXKEY=""
. I $O(^LEX(757.01,"AWRD",LEXKEY2))[LEXKEY S LEXOK=1 Q
. S LEXOK=0
N LEXKEY,LEXKEY2,LEXREC,LEXWRD,LEXOTH,LEXCNT
S (LEXOK,LEXREC)=0,LEXKEY=$O(^TMP("LEXTKN",$J,1,""))
S LEXKEY2=$S($L(LEXKEY)>1:$E(LEXKEY,1,$L(LEXKEY)-1)_$C($A($E(LEXKEY,$L(LEXKEY)))-1)_"~",$L(LEXKEY)=1:$C($A(LEXKEY)-1)_"~",1:"")
I LEXKEY2="" K LEXKEY,LEXKEY2,LEXREC,LEXWRD,LEXOTH,LEXCNT Q 0
F S LEXKEY2=$O(^LEX(757.01,"AWRD",LEXKEY2)) Q:LEXKEY2'[LEXKEY!(LEXOK) D
. S LEXREC=0 F S LEXREC=$O(^LEX(757.01,"AWRD",LEXKEY2,LEXREC)) Q:+LEXREC=0!(LEXOK) D
. . S (LEXCNT,LEXWRD)=1,LEXOTH="" F S LEXWRD=$O(^TMP("LEXTKN",$J,LEXWRD)) Q:+LEXWRD=0 D
. . . S LEXOTH=$O(^TMP("LEXTKN",$J,LEXWRD,""))
. . . S:$$UP^XLFSTR($G(^LEX(757.01,LEXREC,0)))[$$UP^XLFSTR(LEXOTH) LEXCNT=LEXCNT+1
. . . S:LEXCNT=^TMP("LEXTKN",$J,0) LEXOK=1 S:LEXCNT'=^TMP("LEXTKN",$J,0) LEXOK=0
K ^TMP("LEXTKN"),LEXKEY,LEXWRD,LEXREC,LEXCNT,LEXOTH Q LEXOK
ADDEXC(X) ; Boolean function returns:
; 0 Not OK to add X to the Excluded Words file #757.04
; 1 OK to add X to the Excluded Words file #757.04
Q:X="" 0
I +(+($$ISEXC(X))+($$ISREP(X))+($$ISBY(X)))>0 Q 0
Q 1
ISREP(X) ; Boolean function returns:
; 0 If X is not a "Replacement" word
; 1 If X is a "Replacement" word
Q:X="" 0 Q:$D(^LEX(757.05,"AB",$$UP^XLFSTR(X))) 1 Q 0
ISBY(X) ; Boolean function returns:
; 0 If X is not a "Replacement" term
; 1 If X is a "Replacement" term
Q:X="" 0 Q:$D(^LEX(757.04,"C",$$UP^XLFSTR(X))) 1 Q 0
ISEXC(X) ; Boolean function returns:
; 0 If X is not an "Excluded" word
; IFN If X is an "Excluded" word
Q:X="" 0
I $D(^LEX(757.04,"AB",$$UP^XLFSTR(X))) Q $O(^LEX(757.04,"AB",$$UP^XLFSTR(X),0))
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLEXERF 2772 printed Dec 13, 2024@02:08:01 Page 2
LEXERF ;ISL/KER - Functions for Exc/Rep Words ;04/21/2014
+1 ;;2.0;LEXICON UTILITY;**80**;Sep 23, 1996;Build 1
+2 ;
+3 ; Global Variables
+4 ; ^TMP("LEXTKN") SACC 2.3.2.5.1
+5 ;
+6 ; External References
+7 ; $$UP^XLFSTR ICR 10103
+8 ;
EXIST(X) ; Boolean function returns:
+1 ; 0 If X will result in a unsuccessful search (not found)
+2 ; 1 If X will result in a successful search (found)
+3 ; IFN If X has an exact match (found)
+4 if '$DATA(X)
QUIT 0
if X=""
QUIT 0
+5 IF $DATA(^LEX(757.01,"AB",$$UP^XLFSTR(X)))
QUIT $ORDER(^LEX(757.01,"AB",$$UP^XLFSTR(X),0))
+6 NEW LEXOK
DO PTX^LEXTOKN
SET LEXOK=1
+7 IF '$DATA(^TMP("LEXTKN",$JOB,0))
KILL ^TMP("LEXTKN"),LEXOK
QUIT 0
+8 IF ^TMP("LEXTKN",$JOB,0)<1
KILL ^TMP("LEXTKN"),LEXOK
QUIT 0
+9 IF ^TMP("LEXTKN",$JOB,0)=1
Begin DoDot:1
+10 SET LEXKEY=$ORDER(^TMP("LEXTKN",$JOB,1,""))
+11 if $LENGTH(LEXKEY)>1
SET LEXKEY2=$EXTRACT(LEXKEY,1,$LENGTH(LEXKEY)-1)_$CHAR($ASCII($EXTRACT(LEXKEY,$LENGTH(LEXKEY)))-1)_"~"
+12 if $LENGTH(LEXKEY)=1
SET LEXKEY2=$CHAR($ASCII(LEXKEY)-1)_"~"
+13 if $GET(LEXKEY2)=""
SET LEXKEY2=""
+14 if LEXKEY=""
SET LEXOK=0
if LEXKEY=""
QUIT
+15 IF $ORDER(^LEX(757.01,"AWRD",LEXKEY2))[LEXKEY
SET LEXOK=1
QUIT
+16 SET LEXOK=0
End DoDot:1
KILL ^TMP("LEXTKN"),LEXKEY,LEXKEY2
QUIT LEXOK
+17 NEW LEXKEY,LEXKEY2,LEXREC,LEXWRD,LEXOTH,LEXCNT
+18 SET (LEXOK,LEXREC)=0
SET LEXKEY=$ORDER(^TMP("LEXTKN",$JOB,1,""))
+19 SET LEXKEY2=$SELECT($LENGTH(LEXKEY)>1:$EXTRACT(LEXKEY,1,$LENGTH(LEXKEY)-1)_$CHAR($ASCII($EXTRACT(LEXKEY,$LENGTH(LEXKEY)))-1)_"~",$LENGTH(LEXKEY)=1:$CHAR($ASCII(LEXKEY)-1)_"~",1:"")
+20 IF LEXKEY2=""
KILL LEXKEY,LEXKEY2,LEXREC,LEXWRD,LEXOTH,LEXCNT
QUIT 0
+21 FOR
SET LEXKEY2=$ORDER(^LEX(757.01,"AWRD",LEXKEY2))
if LEXKEY2'[LEXKEY!(LEXOK)
QUIT
Begin DoDot:1
+22 SET LEXREC=0
FOR
SET LEXREC=$ORDER(^LEX(757.01,"AWRD",LEXKEY2,LEXREC))
if +LEXREC=0!(LEXOK)
QUIT
Begin DoDot:2
+23 SET (LEXCNT,LEXWRD)=1
SET LEXOTH=""
FOR
SET LEXWRD=$ORDER(^TMP("LEXTKN",$JOB,LEXWRD))
if +LEXWRD=0
QUIT
Begin DoDot:3
+24 SET LEXOTH=$ORDER(^TMP("LEXTKN",$JOB,LEXWRD,""))
+25 if $$UP^XLFSTR($GET(^LEX(757.01,LEXREC,0)))[$$UP^XLFSTR(LEXOTH)
SET LEXCNT=LEXCNT+1
+26 if LEXCNT=^TMP("LEXTKN",$JOB,0)
SET LEXOK=1
if LEXCNT'=^TMP("LEXTKN",$JOB,0)
SET LEXOK=0
End DoDot:3
End DoDot:2
End DoDot:1
+27 KILL ^TMP("LEXTKN"),LEXKEY,LEXWRD,LEXREC,LEXCNT,LEXOTH
QUIT LEXOK
ADDEXC(X) ; Boolean function returns:
+1 ; 0 Not OK to add X to the Excluded Words file #757.04
+2 ; 1 OK to add X to the Excluded Words file #757.04
+3 if X=""
QUIT 0
+4 IF +(+($$ISEXC(X))+($$ISREP(X))+($$ISBY(X)))>0
QUIT 0
+5 QUIT 1
ISREP(X) ; Boolean function returns:
+1 ; 0 If X is not a "Replacement" word
+2 ; 1 If X is a "Replacement" word
+3 if X=""
QUIT 0
if $DATA(^LEX(757.05,"AB",$$UP^XLFSTR(X)))
QUIT 1
QUIT 0
ISBY(X) ; Boolean function returns:
+1 ; 0 If X is not a "Replacement" term
+2 ; 1 If X is a "Replacement" term
+3 if X=""
QUIT 0
if $DATA(^LEX(757.04,"C",$$UP^XLFSTR(X)))
QUIT 1
QUIT 0
ISEXC(X) ; Boolean function returns:
+1 ; 0 If X is not an "Excluded" word
+2 ; IFN If X is an "Excluded" word
+3 if X=""
QUIT 0
+4 IF $DATA(^LEX(757.04,"AB",$$UP^XLFSTR(X)))
QUIT $ORDER(^LEX(757.04,"AB",$$UP^XLFSTR(X),0))
+5 QUIT 0