Changeset 1349
- Timestamp:
- Jan 27, 2012, 10:51:57 PM (13 years ago)
- Location:
- fmts/trunk/p
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fmts/trunk/p/C0XF2N.m
r1343 r1349 416 416 . S FARY="C0XFARY" 417 417 N ZIEN 418 I $G(ZSTRING)="" Q "" ; NO STRING 418 419 S ZIEN=$O(@C0XSN@("B",ZSTRING,"")) 419 420 I ZIEN="" D ; … … 501 502 . S ZIEN=ZI+ZBASE ; the new ien 502 503 . S ^C0X(101,ZIEN,0)=ZN_U_ZG_U_ZS_U_ZP_U_ZO ; set the zero node 503 . S ^C0X(101,"B",ZN,ZIEN)="" ; the B index 504 . S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index 505 . S ^C0X(101,"SPO",ZS,ZP,ZO)="" 506 . S ^C0X(101,"SOP",ZS,ZO,ZP)="" 507 . S ^C0X(101,"OPS",ZO,ZP,ZS)="" 508 . S ^C0X(101,"OSP",ZO,ZS,ZP)="" 509 . S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS)="" 510 . S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP)="" 511 . S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO)="" 512 . S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO)="" 504 . D INDEX(ZIEN,ZN,ZG,ZS,ZP,ZO) 505 Q 506 ; 507 INDEX(ZIEN,ZN,ZG,ZS,ZP,ZO) ; HARD SET THE INDEX FOR ONE ENTRY 508 S ^C0X(101,"B",ZN,ZIEN)="" ; the B index 509 S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index 510 S ^C0X(101,"SPO",ZS,ZP,ZO,ZIEN)="" 511 S ^C0X(101,"SOP",ZS,ZO,ZP,ZIEN)="" 512 S ^C0X(101,"OPS",ZO,ZP,ZS,ZIEN)="" 513 S ^C0X(101,"OSP",ZO,ZS,ZP,ZIEN)="" 514 S ^C0X(101,"PSO",ZP,ZS,ZO,ZIEN)="" 515 S ^C0X(101,"POS",ZP,ZO,ZS,ZIEN)="" 516 S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS,ZIEN)="" 517 S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP,ZIEN)="" 518 S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO,ZIEN)="" 519 S ^C0X(101,"GPOS",ZG,ZP,ZO,ZS,ZIEN)="" 520 S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO,ZIEN)="" 521 S ^C0X(101,"GSOP",ZG,ZS,ZO,ZP,ZIEN)="" 522 Q 523 ; 524 REINDEX ; REINDEX THE ^C0X(101, TRIPLE STORE 525 K ^C0X(101,"B") 526 K ^C0X(101,"G") 527 K ^C0X(101,"SPO") 528 K ^C0X(101,"SOP") 529 K ^C0X(101,"OPS") 530 K ^C0X(101,"OSP") 531 K ^C0X(101,"PSO") 532 K ^C0X(101,"POS") 533 K ^C0X(101,"GOPS") 534 K ^C0X(101,"GOSP") 535 K ^C0X(101,"GPSO") 536 K ^C0X(101,"GPOS") 537 K ^C0X(101,"GSPO") 538 K ^C0X(101,"GSOP") 539 N ZIEN,ZZ 540 S ZIEN=0 541 F S ZIEN=$O(^C0X(101,ZIEN)) Q:+ZIEN=0 D ; FOR EACH NODE 542 . S ZZ=$G(^C0X(101,ZIEN,0)) 543 . I ZZ="" D Q ; 544 . . W !,"ERROR REINDEXING NODE ",ZI 545 . S ZN=$P(ZZ,"^",1) 546 . S ZG=$P(ZZ,"^",2) 547 . S ZS=$P(ZZ,"^",3) 548 . S ZP=$P(ZZ,"^",4) 549 . S ZO=$P(ZZ,"^",5) 550 . D INDEX(ZIEN,ZN,ZG,ZS,ZP,ZO) 513 551 Q 514 552 ; -
fmts/trunk/p/C0XGET1.m
r1343 r1349 26 26 Q 27 27 ; 28 LSGRFS(RTN,C0XFARY) ; LIST ALL GRAPHS28 GRAPHS(RTN,C0XFARY) ; LIST ALL GRAPHS 29 29 ; 30 30 I '$D(C0XFARY) D INITFARY^C0XF2N("C0XFARY") … … 57 57 ; 58 58 NXT(ZRTN) ;EXTRINSIC FOR THE NEXT NODE IN ARRAY ZRTN, PASSED BY REF 59 I '$D(ZRTN) S ZRTN="" 59 60 Q $O(ZRTN(""),-1)+1 60 61 ; … … 62 63 ; 63 64 I '$D(C0XFARY) D INITFARY^C0XF2N("C0XFARY") 65 I '$D(ZRTN) S ZRTN="" 64 66 N ZI,ZN S ZI="" 65 F S ZI=$O(@C0XTN@("GS O",ZG,ZI)) Q:ZI="" D ;66 . S ZRTN($$NXT( ZRTN),"S")=$$STR(ZI)67 F S ZI=$O(@C0XTN@("GSPO",ZG,ZI)) Q:ZI="" D ; 68 . S ZRTN($$NXT(.ZRTN),"S")=$$STR(ZI) 67 69 Q 68 70 ; 71 triples(triplertn,sub,pred,obj,graph,fary) ; returns triples 72 I '$D(fary) D ; 73 . D INITFARY^C0XF2N("C0XFARY") 74 . S fary="C0XFARY" 75 D USEFARY^C0XF2N(fary) 76 k triplertn ; start with a clean return 77 n zsub,zpred,zobj,zgraph,tmprtn 78 s zsub=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(sub)),fary) ; ien of subject 79 s zpred=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(pred)),fary) ; ien of predicate 80 s zobj=$$IENOF^C0XF2N($$EXT^C0XUTIL($g(obj)),fary) ; ien of object 81 s zgraph=$$IENOF^C0XF2N($g(graph),fary) ; ien of graph 82 W !,"s:",zsub," p:",zpred," o:",zobj 83 d trip(.tmprtn,zsub,zpred,zobj,zgraph,fary) 84 n zzz,zrsub,zrpred,zrobj,zgraph 85 s zzz="" 86 f s zzz=$o(tmprtn(zzz)) q:zzz="" d ; 87 . s zrsub=$$GET1^DIQ(C0XTFN,zzz_",",.03,"E") 88 . s zrpred=$$GET1^DIQ(C0XTFN,zzz_",",.04,"E") 89 . s zrobj=$$GET1^DIQ(C0XTFN,zzz_",",.05,"E") 90 . s zrgraph=$$GET1^DIQ(C0XTFN,zzz_",",.02,"E") 91 . s triplertn(zzz)=zrsub_"^"_zrpred_"^"_zrobj ; _"^"_zrgraph 92 q 93 ; 94 trip(triprtn,nsub,npred,nobj,ngraph,fary) ; returns triples iens 95 ; nsub,npred,nobj are all optional 96 ; graf is also optional, and will limit the search to a particular ngraph 97 ; fary is which triple store (not implemented yet) 98 n c0xflag,zi,zx,zt 99 s zt=$na(^C0X(101)) ; 100 n zf1,zf2,zf3 101 s zf1=$s($g(nsub)="":0,1:1) 102 s zf2=$s($g(npred)="":0,1:1) 103 s zf3=$s($g(nobj)="":0,1:1) 104 s c0xflag="I"_zf1_zf2_zf3 105 n itbl 106 s itbl("I000","SPO")="d do3(.triprtn,zt,zi)" 107 s itbl("I001","OSP")="d do2(.triprtn,zt,zi,nobj)" 108 s itbl("I010","PSO")="d do2(.triprtn,zt,zi,npred)" 109 s itbl("I011","POS")="d do1(.triprtn,zt,zi,npred,nobj)" 110 s itbl("I100","SPO")="d do2(.triprtn,zt,zi,nsub)" 111 s itbl("I101","SOP")="d do1(.triprtn,zt,zi,nsub,nobj)" 112 s itbl("I110","SPO")="d do1(.triprtn,zt,zi,nsub,npred)" 113 s itbl("I111","SPO")="d do0(.triprtn,zt,zi,nsub,npred,nobj)" 114 s zi=$o(itbl(c0xflag,"")) 115 s zx=itbl(c0xflag,zi) ; executable instruction to run 116 i $g(ngraph)'="" s zi="G"_zi 117 w !,zx 118 x zx 119 q 120 ; 121 do0(dortn,zt,zi,z1,z2,z3) 122 ; looking for only one triple 123 n zz 124 s zz=$o(@zt@(zi,z1,z2,z3,"")) 125 i zz'="" s dortn(zz)="" 126 q 127 ; 128 do1(dortn,zt,zi,z1,z2) ; have 2, looking for one 129 n zr,zx1 130 s zx1="" 131 f s zx1=$o(@zt@(zi,z1,z2,zx1)) q:zx1="" d ; 132 . s zr=$o(@zt@(zi,z1,z2,zx1,"")) 133 . s dortn(zr)="" 134 q 135 ; 136 do2(dortn,zt,zi,z1) ; have one, looking for 2 137 n zr,zx1,zx2 138 s (zx1,zx2)="" 139 f s zx1=$o(@zt@(zi,z1,zx1)) q:zx1="" d ; 140 . f s zx2=$o(@zt@(zi,z1,zx1,zx2)) q:zx2="" d ; 141 . . s zr=$o(@zt@(zi,z1,zx1,zx2,"")) 142 . . s dortn(zr)="" 143 q 144 ; 145 do3(dortn,zt,zi) ; have none, looking for three 146 n zr,zx1,zx2,zx3 147 s (zx1,zx2,zx3)="" 148 f s zx1=$o(@zt@(zi,zx1)) q:zx1="" d ; 149 . f s zx2=$o(@zt@(zi,zx1,zx2)) q:zx2="" d ; 150 . . f s zx3=$o(@zt@(zi,zx1,zx2,zx3)) q:zx3="" d ; 151 . . . s zr=$o(@zt@(zi,zx1,zx2,zx3,"")) 152 . . . s dortn(zr)="" 153 q 154 ; -
fmts/trunk/p/C0XUTIL.m
r1343 r1349 52 52 S C0XVOC("file")="/home/glilly/fmts/trunk/samples/" 53 53 S C0XVOC("foaf")="http://xmlns.com/foaf/0.1/" 54 S C0XVOC("skos")="http://www.w3.org/2004/02/skos/core#" 55 S C0XVOC("gpl")="http://georgetriples.org/" 56 S C0XVOC("cg")="http://datasets.caregraf.org/" 54 57 Q 55 58 ; 59 EXT(C0XIN) ; EXTRINSIC WHICH EXPANDS NAMESPACES 60 ; SO skos:xxx would return http://www.w3.org/2004/02/skos/core#xxx 61 N C0XPRE 62 S C0XPRE=C0XIN 63 I '$D(C0XVOC) D VOCINIT ; INITIALIZE NAME SPACE TABLE 64 I C0XPRE[":" D ; expand using vocabulary 65 . N ZB,ZA 66 . S ZB=$P(C0XPRE,":",1) 67 . S ZA=$P(C0XPRE,":",2) 68 . I $G(C0XVOC(ZB))'="" D ; 69 . . S C0XPRE=C0XVOC(ZB)_ZA ; expanded 70 Q C0XPRE 71 ;
Note:
See TracChangeset
for help on using the changeset viewer.