- Timestamp:
- Mar 8, 2012, 1:37:26 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmts/trunk/p/C0XGET1.m
r1372 r1373 137 137 q 138 138 ; 139 subjects(listrtn,sub,pred,obj,graph,form,fary) ; return list of subjects 140 d onelist("S") ;subjects 141 q 142 ; 143 preds(listrtn,sub,pred,obj,graph,form,fary) ; return list of subjects 144 d onelist("P") ;subjects 145 q 146 ; 147 objects(listrtn,sub,pred,obj,graph,form,fary) ; return list of subjects 148 d onelist("O") ;subjects 149 q 150 ; 151 onelist(zw) ; returns list 152 ; zw is S P or O depending on what should be returned 153 I '$D(fary) D ; 154 . D INITFARY^C0XF2N("C0XFARY") 155 . S fary="C0XFARY" 156 D USEFARY^C0XF2N(fary) 157 I '$D(form) S form="json" 158 k listrtn ; start with a clean return 159 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 164 W !,"s:",zsub," p:",zpred," o:",zobj 165 n c0xflag,zi,zx,zt 166 s zt=$na(^C0X(101)) ; 167 s c0xflag=$$meta(zsub,zpred,zobj) ; get meta flags 168 k tmprtn 169 n itbl,ii,ix 170 s ii=$s(zw="S":"SPO",zw="P":"POS",zw="O":"OSP") ; no constraint 171 s itbl("I000",ii)="d zip(.tmprtn,zt,zi)" 172 s ii=$s(zw="S":"OSP",zw="P":"OPS",zw="O":"OSP") ; obj constraint 173 s ix=$s(zw="O":"s tmprtn(zobj)=""""",1:"d zip1(.tmprtn,zt,zi,zobj)") 174 s itbl("I001",ii)=ix 175 s itbl("I010","PSO")="d zip1(.tmprtn,zt,zi,zpred)" 176 s itbl("I011","POS")="d zip2(.tmprtn,zt,zi,zpred,zobj)" 177 s itbl("I100","SPO")="d zip(.tmprtn,zt,zi)" 178 s itbl("I101","OSP")="d zip1(.tmprtn,zt,zi,zobj)" 179 s itbl("I110","PSO")="d zip1(.tmprtn,zt,zi,zpred)" 180 s itbl("I111","POS")="d zip2(.tmprtn,zt,zi,zpred,zobj)" 181 s zi=$o(itbl(c0xflag,"")) 182 s zx=itbl(c0xflag,zi) ; executable instruction to run 183 i $g(ngraph)'="" s zi="G"_zi 184 w !,zx 185 x zx 186 k listrtn 187 d strings(.listrtn,"tmprtn") ; convert pointer to strings 188 q 189 ; 190 zip(zrtn,zt,zi) ; pull out just the first element of the index 191 ; 192 n zii s zii="" 193 f s zii=$o(@zt@(zi,zii)) q:zii="" d ; 194 . s zrtn(zii)="" 195 q 196 ; 197 zip1(zrtn,zt,zi,zn) ; pull out just the first element of the index 198 ; 199 n zii s zii="" 200 f s zii=$o(@zt@(zi,zn,zii)) q:zii="" d ; 201 . s zrtn(zii)="" 202 q 203 ; 204 zip2(zrtn,zt,zi,zn,zn1) ; pull out just the first element of the index 205 ; 206 n zii s zii="" 207 f s zii=$o(@zt@(zi,zn,zn1,zii)) q:zii="" d ; 208 . s zrtn(zii)="" 209 q 210 ; 139 211 arrayout(rtn,zary) ; output an array of triples 140 212 ; … … 146 218 . . s rtn(zcnt)=zrsub_"^"_zzz 147 219 . . s zcnt=zcnt+1 220 q 221 ; 222 strings(zrary,zinary) ; convert pointers to strings 223 ; 224 k zrary 225 n zzz s zzz="" 226 f s zzz=$o(@zinary@(zzz)) q:zzz="" d ; 227 . n zs 228 . s zs=$$GET1^DIQ(C0XSFN,zzz_",",.01) 229 . q:zs="" 230 . s zrary(zs)="" 148 231 q 149 232 ; … … 177 260 q 178 261 ; 262 meta(zsub,zpred,zobj) ; function to return meta information 263 ; about the inputs ie I100 for just a subject and no pred or obj 264 n zf1,zf2,zf3,zflag 265 s zf1=$s($g(zsub)="":0,1:1) 266 s zf2=$s($g(zpred)="":0,1:1) 267 s zf3=$s($g(zobj)="":0,1:1) 268 s zflag="I"_zf1_zf2_zf3 269 q zflag 270 ; 179 271 trip(triprtn,nsub,npred,nobj,ngraph,fary) ; returns triples iens 180 272 ; nsub,npred,nobj are all optional … … 183 275 n c0xflag,zi,zx,zt 184 276 s zt=$na(^C0X(101)) ; 185 n zf1,zf2,zf3 186 s zf1=$s($g(nsub)="":0,1:1) 187 s zf2=$s($g(npred)="":0,1:1) 188 s zf3=$s($g(nobj)="":0,1:1) 189 s c0xflag="I"_zf1_zf2_zf3 277 s c0xflag=$$meta(nsub,npred,nobj) ; get meta flags 190 278 n itbl 191 279 s itbl("I000","SPO")="d do3(.triprtn,zt,zi)"
Note:
See TracChangeset
for help on using the changeset viewer.