added fileman output transform using namespaces

This commit is contained in:
george 2011-12-13 19:41:53 +00:00
parent cecde026df
commit e166aa6e82
4 changed files with 3533 additions and 5 deletions

3338
kids/C0X_1_0_0_T8.KID Normal file

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@ INITFARY(ZFARY) ; INITIALIZE FILE NUMBERS AND OTHER USEFUL THINGS
S @ZFARY@("C0XSFN")=172.201 ; TRIPLES STRINGS FILE NUMBER
S @ZFARY@("C0XTN")=$NA(^C0X(101)) ; TRIPLES GLOBAL NAME
S @ZFARY@("C0XSN")=$NA(^C0X(201)) ; STRING FILE GLOBAL NAME
S @ZFARY@("C0XDIR")="/home/glilly/fmts/trunk/samples/"
S @ZFARY@("C0XDIR")="/home/glilly/snomed/"
S @ZFARY@("BLKLOAD")=1 ; this file supports block load
S @ZFARY@("FMTSSTYLE")="F2N" ; fileman style
D USEFARY(ZFARY)
@ -103,7 +103,7 @@ IMPORT(FNAME,INDIR,INURL,FARY) ; EXTRINSIC THAT READS A FILE FROM THE STANDARD
D INSRDF(ZRDF,INURL,FARY) ; IMPORT AND PROCESS THE RDF
K INURL
K C0XFDA
K ^TMP("MXMLDOM",$J)
;K ^TMP("MXMLDOM",$J)
Q
;
WGET(ZURL,FARY) ; GET FROM THE INTERNET AN RDF FILE AND INSERT IT
@ -220,6 +220,7 @@ PROCESS(ZRTN,ZRDF,ZGRF,ZMETA,FARY) ; PROCESS AN INCOMING RDF FILE
;S C0XDOCID=$$PARSE^C0CNHIN(ZRDF,"C0XARRAY") ; PARSE WITH MXML
S C0XDLC2=$$NOW^XLFDT ; START OF PARSE
S C0XDOCID=$$EN^MXMLDOM(ZRDF,"W")
;B
K @ZRDF ; DON'T NEED INPUT BUFFER ANYMORE
; -- assign the MXLM dom global name to ZDOM
S ZDOM=$NA(^TMP("MXMLDOM",$J,C0XDOCID))
@ -251,13 +252,16 @@ PROCESS(ZRTN,ZRDF,ZGRF,ZMETA,FARY) ; PROCESS AN INCOMING RDF FILE
F S ZI=$O(@ZDOM@(1,"A",ZI)) Q:ZI="" D ; FOR EACH xmlns
. S ZVOC=$P(ZI,"xmlns:",2)
. I ZVOC'="" S C0XVOC(ZVOC)=$G(@ZDOM@(1,"A",ZI))
;W !,"VOCABS:" ZWR C0XVOC
W !,"VOCABS:" ZWR C0XVOC
;
; -- look for children called rdf:Description. quit if none. not an rdf file
;
S C0XTYPE("rdf:Description")=1
S C0XTYPE("owl:ObjectProperty")=1
S ZI=$O(@ZDOM@(1,"C",""))
I $G(@ZDOM@(1,"C",ZI))'="rdf:Description" D Q ; not an rdf file
I '$G(C0XTYPE(@ZDOM@(1,"C",ZI))) D Q ; not an rdf file
. W !,"Error. Not an RDF file. Cannot process."
. zwr ^TMP("MXMLDOM",$J,*)
;
; -- now process the rdf description children
;
@ -267,7 +271,7 @@ PROCESS(ZRTN,ZRDF,ZGRF,ZMETA,FARY) ; PROCESS AN INCOMING RDF FILE
. ; -- we are skipping any child that is not rdf:Description
. ; -- TODO: check to see if this is right in general
. ;
. IF $G(@ZDOM@(1,"C",ZI))'="rdf:Description" D Q ;
. IF '$G(C0XTYPE(@ZDOM@(1,"C",ZI))) D Q ;
. . W !,"SKIPPING NODE: ",ZI
. ; -- now looking for the subject for the triples
. S ZX=$G(@ZDOM@(ZI,"A","rdf:about"))

131
p/C0XTKSB.m Normal file
View File

@ -0,0 +1,131 @@
C0XTESTKSB ; GPL - Fileman Triples bulk load tester ;11/6/11 17:05
; KSB - modified to fix a minor bug and to use
; high resolution time if routines available ; 11/19/11 1410 EST
;;0.1;C0X;nopatch;noreleasedate;Build 1
;Copyright 2011 George Lilly. Licensed under the terms of the GNU
;General Public License See attached copy of the License.
;
;This program is free software; you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License along
;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;
Q
;
EN ; run the test
;
k C0XFDA ; clear the node variable
s U="^" ; initialization - Bhaskar 20111119
i '$d(^C0X(101,0)) d ; global doesn't exist
. s ^C0X(101,0)="C0X TRIPLE^172.101^1^1"
n zg
S zg="_:G"_$$LKY9 ; all nodes are in the same graph
n zi
f zi=1:1:10000 d ; try a test of 10000 nodes
. s C0XFDA(172.101,zi,.01)="N"_$$LKY17 ; node name
. s C0XFDA(172.101,zi,.02)=zg
. s C0XFDA(172.101,zi,.03)=$R(100000)
. s C0XFDA(172.101,zi,.04)=$R(100000)
. s C0XFDA(172.101,zi,.05)=$R(100000)
S C0XST=$$H ; start of the insertion test
W !,"INSERTION STARTS AT ",$ZDATE(C0XST,"YEAR-MM-DD:24:60:SS"),!
d BULKLOAD(.C0XFDA)
s C0XEND=$$H ; end of the insertion test
W !,"INSERTION ENDS AT ",$ZDATE(C0XEND,"YEAR-MM-DD:24:60:SS")
S C0XDIFF=(86400*($P(C0XEND,",",1)-$P(C0XST,",",1)))+$P(C0XEND,",",2)-$P(C0XST,",",2)
W !," ELAPSED TIME: ",C0XDIFF," SECONDS"
W !
W:C0XDIFF>0 " APPROXIMATELY ",$FN(10000/C0XDIFF,",",0)," NODES PER SECOND",!
q
;
LKY9() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING
; UNIQUE NODE AND GRAPH NAMES
N ZN,ZI
S ZN=""
F ZI=1:1:9 D ;
. S ZN=ZN_$R(10)
Q ZN
;
LKY17() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING
; UNIQUE NODE AND GRAPH NAMES
N ZN,ZI
S ZN=""
F ZI=1:1:17 D ;
. S ZN=ZN_$R(10)
Q ZN
;
BULKLOAD(ZBFDA) ; BULK LOADER FOR LOADING TRIPLES INTO FILE 172.101
; USING GLOBAL SETS INSTEAD OF UPDATE^DIE
; QUITS IF FILE IS NOT 172.101
; EXPECTS AN FDA WITHOUT STRINGS FOR THE IENS, STARTING AT 1
; QUITS IF FIRST ENTRY IS NOT IENS 1
; ASSUMES THAT THE LAST IENS IS THE COUNT OF ENTRIES
; ZBFDA IS PASSED BY REFERENCE
;
; -- reserves a block of iens from file 172.101 by locking the zero node
; -- ^C0X(101,0) and adding the count of entries to piece 2 and 3
; -- then unlocking to minimize the duration of the lock
;
W !,"USING BULKLOAD"
I '$D(ZBFDA) Q ; EMPTY FDA
I $O(ZBFDA(""))'=172.101 Q ; WRONG FILE
N ZCNT,ZP3,ZP4
; -- find the number of nodes to insert
S ZCNT=$O(ZBFDA(172.101,""),-1)
I ZCNT="" D Q ;
. W !,"ERROR IN BULK LOAD - INVALID NODE COUNT"
. B
; -- lock the zero node and reserve a block of iens to insert
W !,"LOCKING ZERO NODE"
LOCK +^C0X(101,0)
S ZP3=$P(^C0X(101,0),U,3)
S ZP4=$P(^C0X(101,0),U,4)
S $P(^C0X(101,0),U,3)=ZP3+ZCNT+1
S $P(^C0X(101,0),U,4)=ZP4+ZCNT+1
LOCK -^C0X(101,0)
N ZI,ZN,ZG,ZS,ZP,ZO,ZIEN,ZBASE
S ZBASE=ZP3 ; the last ien in the file
W !,"ZERO NODE UNLOCKED, IENS RESERVED=",ZCNT
W !,$ZDATE($$H,"YEAR-MM-DD:24:60:SS")
S ZI=""
F S ZI=$O(ZBFDA(172.101,ZI)) Q:ZI="" D ;
. S ZN=$G(ZBFDA(172.101,ZI,.01)) ; node name
. I ZN="" D BLKERR Q ;
. S ZG=$G(ZBFDA(172.101,ZI,.02)) ; graph pointer
. I ZG="" D BLKERR Q ;
. S ZS=$G(ZBFDA(172.101,ZI,.03)) ; subject pointer
. I ZS="" D BLKERR Q ;
. S ZP=$G(ZBFDA(172.101,ZI,.04)) ; predicate pointer
. I ZP="" D BLKERR Q ;
. S ZO=$G(ZBFDA(172.101,ZI,.05)) ; object pointer
. I ZO="" D BLKERR Q ;
. S ZIEN=ZI+ZBASE ; the new ien
. S ^C0X(101,ZIEN,0)=ZN_U_ZG_U_ZS_U_ZP_U_ZO ; set the zero node
. S ^C0X(101,"B",ZN,ZIEN)="" ; the B index
. S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index
. S ^C0X(101,"SPO",ZS,ZP,ZO)=""
. S ^C0X(101,"SOP",ZS,ZO,ZP)=""
. S ^C0X(101,"OPS",ZO,ZP,ZS)=""
. S ^C0X(101,"OSP",ZO,ZS,ZP)=""
. S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS)=""
. S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP)=""
. S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO)=""
. S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO)=""
Q
;
BLKERR ;
W !,"ERROR IN BULK LOAD",! ZWR ZBFDA(ZI)
B
Q
;
H()
quit:$length($ztrnlnm("GTMXC_posix"))&$length($text(zhorolog^%POSIX)) $$zhorolog^%POSIX quit $horolog

55
p/C0XUTIL.m Normal file
View File

@ -0,0 +1,55 @@
C0XUTIL ; GPL - Fileman Triples utilities ;11/07/11 17:05
;;0.1;C0X;nopatch;noreleasedate;Build 5
;Copyright 2011 George Lilly. Licensed under the terms of the GNU
;General Public License See attached copy of the License.
;
;This program is free software; you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License along
;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;
Q
;
NSP(ZX) ; OUTPUT TRANSFORM EXTRINSIC
;
N ZR
; I WOULD REALLY LIKE TO NOT HAVE THE FILE NUMBER HARD CODED HERE
; ANYONE KNOW HOW I COULD DO THAT? :) GPL
S ZR=$$GET1^DIQ(172.201,ZX_",",.01)
I '$D(C0XNSP) S C0XNSP=1 ; DEFAULT ON
I C0XNSP=0 Q ZR ; SWITCHED OFF
I '$D(C0XVOC) D VOCINIT ; INITIALIZE THE VOCABULARIES
N ZI,ZJ,ZK S ZI=""
N DONE S DONE=0
F S ZI=$O(C0XVOC(ZI)) Q:(DONE=1)!(ZI="") D ;
. ;W !,ZI
. S ZJ=C0XVOC(ZI)
. S ZK=$P(ZR,ZJ,2)
. ;W !,"ZK=",ZK
. I ZK'="" D ; BINGO
. . S ZR=ZI_":"_ZK
. . S DONE=1
Q ZR
;
VOCINIT ; INITIALIZE VOCABULARIES
S C0XVOC("dcterms")="http://purl.org/dc/terms/"
S C0XVOC("rdf")="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
S C0XVOC("sp")="http://smartplatforms.org/terms#"
S C0XVOC("qds")="http://cms.gov/pqri/qds/"
S C0XVOC("smart")="http://sandbox-api.smartplatforms.org/records/"
S C0XVOC("snomed")="http://www.ihtsdo.org/snomed-ct/concepts/"
S C0XVOC("rxnorm")="http://rxnav.nlm.nih.gov/REST/rxcui/"
S C0XVOC("loinc")="http://loinc.org/codes/"
S C0XVOC("file")="/home/glilly/fmts/trunk/samples/"
S C0XVOC("foaf")="http://xmlns.com/foaf/0.1/"
Q
;