From aeff2fb2f666f928ea0bf4e940e53f819df4383b Mon Sep 17 00:00:00 2001 From: george Date: Sat, 5 May 2012 19:35:48 +0000 Subject: [PATCH] new handy utilities for transforming triples to mumps and back again --- p/C0XXFRM.m | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 p/C0XXFRM.m diff --git a/p/C0XXFRM.m b/p/C0XXFRM.m new file mode 100644 index 0000000..c31f55e --- /dev/null +++ b/p/C0XXFRM.m @@ -0,0 +1,63 @@ +C0XXFRM ; GPL - Fileman Triples utilities ;11/07/11 17:05 + ;;0.1;C0X;nopatch;noreleasedate;Build 7 + ;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 + ; +TEST1 ; test GRAPHY + ; + S G("positiveMatch",18262)="" + S G("positiveMatch",18262,"DOB")="19520606^19520606" + S G("positiveMatch",18262,"FNAME")="GEORGE^GEORGE PHILLIP" + S G("positiveMatch",18262,"LNAME")="LILLY^LILLY" + S G("positiveMatch",18262,"SSN")=310449999 + S GRAPH="/test/gpl/graph" + S SUBJECT="/test/gpl/match" + D GRAPHY("G2","G",GRAPH,SUBJECT) ; CONVERT TO GRAPH + ZWR G2 + ; + Q + ; +TEST2 ; test ARRAYIFY + ; + Q + ; +GRAPHY(ZOUT,ZIN,ZGRF,ZSUB,ZWHICH) ; turn a mumps array into triples + W !,"GRAPHY: ZOUT=",ZOUT," ZIN=",ZIN," ZSUB=",ZSUB," ZWHICH=",$G(ZWHICH),! + N ZI S ZI=$G(ZWHICH) + N ZP + S ZP=$O(@ZIN@(ZI)) + W !,"ZP=",ZP + I ZP="" Q ; THE WAY OUT + N ZJ S ZJ="" + F S ZJ=$O(@ZIN@(ZP,ZJ)) Q:ZJ="" D ; for each object + . N ZO + . S ZO=$$ANONS^C0XF2N ; anonomous subject + . S @ZOUT@(ZSUB,ZP)=ZO + . S @ZOUT@(ZO,"rdf:id")=ZJ + . N ZK S ZK="" + . F S ZK=$O(@ZIN@(ZP,ZJ,ZK)) Q:ZK="" D ; + . . S @ZOUT@(ZO,ZK)=$G(@ZIN@(ZP,ZJ,ZK)) + . . D GRAPHY(ZOUT,$NA(@ZIN@(ZP,ZJ,ZK)),ZGRF,ZO) + ; + Q + ; +ARRAYIFY(ZOUT,ZIN,ZWHICH) ; turn triples into a mumps array (opposite of GRAPHY) + ; + Q + ; \ No newline at end of file