Changeset 1376 for fmts/trunk/p


Ignore:
Timestamp:
Mar 10, 2012, 12:16:58 AM (13 years ago)
Author:
George Lilly
Message:

more on objects preds subjects

Location:
fmts/trunk/p
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fmts/trunk/p/C0XF2N.m

    r1372 r1376  
    440440 Q ZN
    441441 ;
     442 ; these routines add the string if it is not found
     443 ;
    442444IENOF(ZSTRING,FARY) ; EXTRINSIC WHICH RETURNS THE IEN OF ZS IN THE STRINGS FILE
    443445 I '$D(FARY) D  ;
  • fmts/trunk/p/C0XGET1.m

    r1374 r1376  
    123123 k triplertn ; start with a clean return
    124124 n zsub,zpred,zobj,zgraph,tmprtn
    125  s zsub=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(sub)),fary) ; ien of subject
    126  s zpred=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(pred)),fary) ; ien of predicate
    127  s zobj=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(obj)),fary) ; ien of object
    128  s zgraph=$$IENOF^C0XF2N($g(graph),fary) ; ien of graph
     125 s zsub=$$IENOF($$EXT^C0XUTIL($g(sub)),fary) ; ien of subject
     126 s zpred=$$IENOF($$EXT^C0XUTIL($g(pred)),fary) ; ien of predicate
     127 s zobj=$$IENOF($$EXT^C0XUTIL($g(obj)),fary) ; ien of object
     128 s zgraph=$$IENOF($g(graph),fary) ; ien of graph
    129129 W !,"s:",zsub," p:",zpred," o:",zobj
    130130 d trip(.tmprtn,zsub,zpred,zobj,zgraph,fary)
     
    146146 ;
    147147objects(listrtn,sub,pred,obj,graph,form,fary) ; return list of subjects
    148  d onelist("O") ;subjects
    149  q
    150  ;
    151 onelist(zw) ; returns list
     148 d onelist("O",$g(sub),$g(pred),"",$g(fary)) ;subjects
     149 q
     150 ;
     151onelist(zw,sub,pred,obj,fary) ; returns list
    152152 ; zw is S P or O depending on what should be returned
    153  I '$D(fary) D  ;
     153 I $g(fary)="" D  ;
    154154 . D INITFARY^C0XF2N("C0XFARY")
    155155 . S fary="C0XFARY"
     
    158158 k listrtn ; start with a clean return
    159159 n zsub,zpred,zobj,zgraph,tmprtn
    160  s zsub=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(sub)),fary) ; ien of subject
    161  s zpred=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(pred)),fary) ; ien of predicate
    162  s zobj=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(obj)),fary) ; ien of object
    163  s zgraph=$$IENOF^C0XF2N($g(graph),fary) ; ien of graph
     160 s zsub=$$IENOF($$EXT^C0XUTIL($g(sub)),fary) ; ien of sub
     161 s zpred=$$IENOF($$EXT^C0XUTIL($g(pred)),fary) ; ien of pred
     162 s zobj=$$IENOF($$EXT^C0XUTIL($g(obj)),fary) ; ien of obj
     163 s zgraph=$$IENOF($g(graph),fary) ; ien of graph
    164164 W !,"s:",zsub," p:",zpred," o:",zobj
    165165 n c0xflag,zi,zx,zt
    166166 s zt=$na(^C0X(101)) ;
    167  s c0xflag=$$meta(zsub,zpred,zobj) ; get meta flags
     167 s c0xflag=$$mask(zsub,zpred,zobj) ; get mask flags
    168168 k tmprtn
    169169 n itbl,ii,ix
     
    173173 s ix=$s(zw="O":"d just(zobj)",1:"d zip1(.tmprtn,zt,zi,zobj)")
    174174 s itbl("I001",ii)=ix
    175  s ii=$s(zw="S":"PSO",zw="P":"POS",zw="O":"OPS") ; pred constraint
    176  s ix=$s(zw="O":"d just(zpred)",1:"d zip1(.tmprtn,zt,zi,zpred)")
    177  s itbl("I010","PSO")=ix
     175 s ii=$s(zw="S":"PSO",zw="P":"POS",zw="O":"POS") ; pred constraint
     176 s ix=$s(zw="P":"d just(zpred)",1:"d zip1(.tmprtn,zt,zi,zpred)")
     177 s itbl("I010",ii)=ix
    178178 s ii=$s(zw="S":"POS",zw="P":"OPS",zw="O":"OSP") ; pred + obj constraint
    179179 s ix=$s(zw="S":"d zip2(.tmprtn,zt,zi,zpred,zobj)",zw="P":"d just(zpred)",zw="O":"d just(zobj)",1:"d just(zobj)")
    180  s itbl("I011","POS")=ix
    181  s itbl("I100","SPO")="d zip(.tmprtn,zt,zi)"
    182  s itbl("I101","OSP")="d zip1(.tmprtn,zt,zi,zobj)"
    183  s itbl("I110","PSO")="d zip1(.tmprtn,zt,zi,zpred)"
    184  s itbl("I111","POS")="d zip2(.tmprtn,zt,zi,zpred,zobj)"
    185  s zi=$o(itbl(c0xflag,""))
     180 s itbl("I011",ii)=ix
     181 s ii=$s(zw="S":"SPO",zw="P":"SPO",zw="O":"SOP") ; sub constraint
     182 s ix=$s(zw="S":"d just(zsub)",1:"d zip1(.tmprtn,zt,zi,zsub)")
     183 s itbl("I100",ii)=ix
     184 s ii=$s(zw="S":"SPO",zw="P":"SOP",zw="O":"OSP") ; sub + obj constraint
     185 s ix=$s(zw="P":"d zip2(.tmprtn,zt,zi,zsub,zobj)",zw="S":"d just(zsub)",zw="O":"d just(zobj)",1:"d just(zobj)")
     186 s itbl("I101",ii)=ix
     187 s ii=$s(zw="S":"SPO",zw="P":"POS",zw="O":"SPO") ; sub + pred constraint
     188 s ix=$s(zw="O":"d zip2(.tmprtn,zt,zi,zsub,zpred)",zw="S":"d just(zsub)",zw="P":"d just(zpred)",1:"d just(zsub)")
     189 s itbl("I110",ii)=ix
     190 s ii=$s(zw="S":"SPO",zw="P":"POS",zw="O":"OSP") ; sub + pred + obj constraint
     191 s ix=$s(zw="O":"d just(zobj)",zw="S":"d just(zsub)",zw="P":"d just(zpred)",1:"d just(zsub)")
     192 s itbl("I111",ii)=ix
     193 ; end itbl definition
     194 ;
     195 s zi=$o(itbl(c0xflag,"")) ; find index to use
    186196 s zx=itbl(c0xflag,zi) ; executable instruction to run
    187  i $g(ngraph)'="" s zi="G"_zi
    188  w !,zx
     197 ;i $g(ngraph)'="" s zi="G"_zi ; this is wrong.. don't do graphs yet
     198 w !,c0xflag," ",zw," ",zt," ",zi," ",zx,!
     199 ;zwr itbl
    189200 x zx
    190201 k listrtn
     
    268279 q
    269280 ;
    270 meta(zsub,zpred,zobj) ; function to return meta information
     281mask(zsub,zpred,zobj) ; function to return mask information
    271282 ; about the inputs ie I100 for just a subject and no pred or obj
    272283 n zf1,zf2,zf3,zflag
     
    283294 n c0xflag,zi,zx,zt
    284295 s zt=$na(^C0X(101)) ;
    285  s c0xflag=$$meta(nsub,npred,nobj) ; get meta flags
     296 s c0xflag=$$mask(nsub,npred,nobj) ; get mask flags
    286297 n itbl
    287298 s itbl("I000","SPO")="d do3(.triprtn,zt,zi)"
     
    333344 . . . s dortn(zr)=""
    334345 q
     346 ;
     347IENOF(ZSTRING,FARY) ; EXTRINSIC WHICH RETURNS THE IEN OF ZS IN THE STRINGS FILE
     348 I '$D(FARY) D  ;
     349 . D INITFARY^C0XF2N("C0XFARY")
     350 . S FARY="C0XFARY"
     351 N ZIEN
     352 I $G(ZSTRING)="" Q "" ; NO STRING
     353 S ZIEN=$O(@C0XSN@("B",ZSTRING,""))
     354 Q ZIEN
     355 ;
     356IENOFA(ZOUTARY,INARY,FARY) ; RESOLVE STRINGS TO IEN IN STRINGS FILE
     357 ; RETURNS IN ZOUTARY OF THE FORM ZOUTARY("IEN","VAR",IEN)=""
     358 I '$D(FARY) D  ;
     359 . D INITFARY^C0XF2N("C0XFARY")
     360 . S FARY="C0XFARY"
     361 K ZOUTARY ; START WITH CLEAN RESULTS
     362 K C0XFDA2 ; USE A SEPARATE FDA FOR THIS
     363 I '$D(C0XVOC) D VOCINIT^C0XUTIL
     364 N ZINARY
     365 N ZI S ZI=""
     366 F  S ZI=$O(INARY(ZI)) Q:ZI=""  D  ;
     367 . N ZK
     368 . S ZK=$O(INARY(ZI,""))
     369 . S ZINARY($$EXT^C0XUTIL(ZI),$$EXT^C0XUTIL(ZK))=""
     370 N ZV,ZIEN
     371 N ZCNT S ZCNT=0
     372 F  S ZI=$O(ZINARY(ZI)) Q:ZI=""  D  ; LOOK FOR MISSING STRINGS
     373 . S ZV=$O(ZINARY(ZI,""))
     374 . I ZV["^" S ZV=$TR(ZV,"^","|")
     375 F  S ZI=$O(ZINARY(ZI)) Q:ZI=""  D  ; NOW GET ALL IENS
     376 . S ZV=$O(ZINARY(ZI,""))
     377 . I ZV["^" S ZV=$TR(ZV,"^","|")
     378 . S ZIEN=$O(@C0XSN@("B",ZV,"")) ; THEY SHOULD BE THERE NOW
     379 . I ZIEN="" S ZOUTARY("IEN",ZI)=""
     380 . E  S ZOUTARY("IEN",ZI,ZIEN)=""
     381 Q
    335382 ;
    336383output(zwhat,zfname,zdir) ; function to write an array to a host file
Note: See TracChangeset for help on using the changeset viewer.