]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter_galax/2use.ml
commit of galax mathql interpreter
[helm.git] / helm / ocaml / mathql_interpreter_galax / 2use.ml
diff --git a/helm/ocaml/mathql_interpreter_galax/2use.ml b/helm/ocaml/mathql_interpreter_galax/2use.ml
new file mode 100644 (file)
index 0000000..9a69db2
--- /dev/null
@@ -0,0 +1,62 @@
+open Mathql_semantics;;
+
+
+(* prende una lista di uri (contenente alternativamente uri e pos) e costruisce una lista di attributed_uri *)
+let rec attl uril svar = 
+
+            match uril with
+              | head::tail ->
+               let suri = List.hd uril in
+       
+                 let uril_tl = List.tl uril in
+
+
+             {uri = suri; attributes = [(svar, (List.hd
+              uril_tl))]; extra = ""} :: attl (List.tl uril_tl) svar (*
+                                                NON SONO SICURO DI AVER COSTRUITO BENE LA STRUTTURA DATI!!!!*)
+              | [] -> [] 
+
+
+
+
+
+(* prende un attributed_uri e una svar e  restituisce la lista degli
+attributed_uri (backward o forward in base al parametro "d") associando
+la posizione alla var passata *)
+
+let muse svar d path = 
+        let dir =
+          match d with
+              "F" -> "/home/projects/helm/metadata/create4/forward"
+            | _ -> "/home/projects/helm/metadata/create4/backward"
+        in 
+          let dtag =
+            match d with
+              "F" -> "refObj"
+            | _ -> "backPointer" in
+
+          let xq ="namespace h=\"http://www.cs.unibo.it/helm/schemas/mattone.rdf#\"
+                   namespace rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
+                for $i in document(" ^ "\"" ^ dir ^ path.uri ^ "\"" ^
+                ")//rdf:RDF//h:Object//h:" ^ dtag ^ "//h:Occurrence
+                return ($i//h:occurrence, $i//h:position)"
+        
+          in 
+         print_endline xq;
+            let uril = Toputils.eval_query_string xq in (* e' una lista di liste di stringhe*)
+             let  hd_uril = List.hd uril in(*prendo l'elemento in testa che e' quello
+                                      che contiene la lista di uri*)
+        
+       attl hd_uril svar (* adesso dalla lista di uri(hd_uril) costruisco una lista di attributed_uri*)
+
+            
+
+
+(* prende una lista di uri (Mathql_semantics.result), una variabile (a cui
+associare la posizione), e la direzione (forward o backward) e per ogni uri chiama la muse *)
+let use_ex ulist svar d = 
+      List.concat (List.map (muse svar d) ulist) 
+;;
+
+
+