From: natile Date: Thu, 17 Oct 2002 17:55:17 +0000 (+0000) Subject: Fun implemented. X-Git-Tag: mathql~1 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fnew_mathql;p=helm.git Fun implemented. --- diff --git a/helm/ocaml/mathql_interpreter/.depend b/helm/ocaml/mathql_interpreter/.depend index 8106a0f5e..72a3dd440 100644 --- a/helm/ocaml/mathql_interpreter/.depend +++ b/helm/ocaml/mathql_interpreter/.depend @@ -14,6 +14,8 @@ sub.cmo: sub.cmi sub.cmx: sub.cmi intersect.cmo: intersect.cmi intersect.cmx: intersect.cmi +func.cmo: dbconn.cmi intersect.cmi utility.cmi func.cmi +func.cmx: dbconn.cmx intersect.cmx utility.cmx func.cmi mqint.cmo: context.cmo dbconn.cmi diff.cmi intersect.cmi meet.cmi \ relation.cmi sub.cmi union.cmi mqint.cmi mqint.cmx: context.cmx dbconn.cmx diff.cmx intersect.cmx meet.cmx \ diff --git a/helm/ocaml/mathql_interpreter/Makefile b/helm/ocaml/mathql_interpreter/Makefile index 7a45ecdf2..cd63e8ab4 100644 --- a/helm/ocaml/mathql_interpreter/Makefile +++ b/helm/ocaml/mathql_interpreter/Makefile @@ -2,9 +2,9 @@ PACKAGE = mathql_interpreter REQUIRES = helm-urimanager postgres unix helm-mathql PREDICATES = -INTERFACE_FILES = dbconn.mli utility.mli union.mli relation.mli diff.mli meet.mli sub.mli intersect.mli mqint.mli +INTERFACE_FILES = dbconn.mli utility.mli union.mli relation.mli diff.mli meet.mli sub.mli intersect.mli func.mli mqint.mli -IMPLEMENTATION_FILES = dbconn.ml utility.ml union.ml relation.ml diff.ml meet.ml sub.ml intersect.ml context.ml mqint.ml +IMPLEMENTATION_FILES = dbconn.ml utility.ml union.ml relation.ml diff.ml meet.ml sub.ml intersect.ml context.ml func.ml mqint.ml # $(INTERFACE_FILES:%.mli=%.ml) diff --git a/helm/ocaml/mathql_interpreter/func.ml b/helm/ocaml/mathql_interpreter/func.ml index 857a4c698..1338af008 100644 --- a/helm/ocaml/mathql_interpreter/func.ml +++ b/helm/ocaml/mathql_interpreter/func.ml @@ -29,65 +29,28 @@ open Dbconn;; open Utility;; -open MathQL;; - -(* - * implementazione della funzione NAME - * - * esempio: - * name "cic:/Algebra/CC_Props/CC_CauchySeq.ind#xpointer(1/1/1)" = CC_CauchySeq - *) -let func_name value = - try ( - let i = Str.search_forward (Str.regexp "[^/]*\.") value 0 in - let s = Str.matched_string value in - let retVal = Str.string_before s ((String.length s) - 1) in - retVal - ) with - Not_found -> "" -;; - -(* - * - *) -let func_theory value = - "" -;; +open Intersect;; (* * implementazione delle funzioni dublin core *) -let func_dc (value, name) = - let c = pgc () - and p = helm_property_id name in - pgresult_to_string (c#exec ("select t" ^ p ^ ".att1 from t" ^ p ^ " where " ^ "t" ^ p ^ ".att0 = '" ^ value ^ "'")) +let rec func_dc tab outv inv = function + [] -> [] + | s::tl -> let res = + let c = pgc () in + let q = ("select " ^ tab ^ "." ^ outv ^ " from " ^ tab ^ " where " ^ tab ^ "." ^ inv ^ " = '" ^ s ^ "'") in + pgresult_to_string_list (c#exec q) + in + append (res,(func_dc tab outv inv tl)) ;; (* * *) -let apply_func f value = +let fun_ex f value = match f with - MQName -> func_name value - | MQTheory -> func_theory value - | MQTitle -> func_dc (value, "title") - | MQContributor -> func_dc (value, "contributor") - | MQCreator -> func_dc (value, "creator") - | MQPublisher -> func_dc (value, "publisher") - | MQSubject -> func_dc (value, "subject") - | MQDescription -> func_dc (value, "description") - | MQDate -> func_dc (value, "date") - | MQType -> func_dc (value, "type") - | MQFormat -> func_dc (value, "format") - | MQIdentifier -> func_dc (value, "identifier") - | MQLanguage -> func_dc (value, "language") - | MQRelation -> func_dc (value, "relation") - | MQSource -> func_dc (value, "source") - | MQCoverage -> func_dc (value, "coverage") - | MQRights -> func_dc (value, "rights") - | MQInstitution -> func_dc (value, "institution") - | MQContact -> func_dc (value, "contact") - | MQFirstVersion -> func_dc (value, "firstversion") - | MQModified -> func_dc (value, "modified") + "name" -> func_dc "names" "name" "uri" value + | "reference" -> func_dc "names" "uri" "name" value + | _ -> [] ;; diff --git a/helm/ocaml/mathql_interpreter/func.mli b/helm/ocaml/mathql_interpreter/func.mli index fb68df82a..2858ce0da 100644 --- a/helm/ocaml/mathql_interpreter/func.mli +++ b/helm/ocaml/mathql_interpreter/func.mli @@ -23,4 +23,4 @@ * http://cs.unibo.it/helm/. *) -val apply_func: MathQL.mqfunc -> string -> string +val fun_ex: string -> MathQL.value -> MathQL.value diff --git a/helm/ocaml/mathql_interpreter/intersect.mli b/helm/ocaml/mathql_interpreter/intersect.mli index 956a05922..5045162b6 100644 --- a/helm/ocaml/mathql_interpreter/intersect.mli +++ b/helm/ocaml/mathql_interpreter/intersect.mli @@ -25,3 +25,6 @@ val intersect_ex : MathQL.result -> MathQL.result -> MathQL.result + +val append: + (string list * string list) -> string list diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index c45f9dee8..f4f7e5241 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -41,7 +41,7 @@ open Sub;; open Context;; open Diff;; open Relation;; - +open Func;; let init connection_param = Dbconn.init connection_param @@ -60,8 +60,8 @@ let get_stat () = ! stat (* valuta una MathQL.set_exp e ritorna un MathQL.resource_set *) let rec exec_set_exp c = function - |MathQL.SVar svar -> List.assoc svar c.svars - |MathQL.RVar rvar -> [List.assoc rvar c.rvars] + MathQL.SVar svar -> List.assoc svar c.svars + | MathQL.RVar rvar -> [List.assoc rvar c.rvars] | MathQL.Ref vexp -> List.map (fun s -> (s,[])) (exec_val_exp c vexp) | MathQL.Intersect (sexp1, sexp2) -> let before = Sys.time() in @@ -134,7 +134,7 @@ let rec exec_set_exp c = function (* valuta una MathQL.boole_exp e ritorna un boole *) and exec_boole_exp c = function - | MathQL.False -> false + MathQL.False -> false | MathQL.True -> true | MathQL.Not x -> not (exec_boole_exp c x) | MathQL.And (x, y) -> (exec_boole_exp c x) && (exec_boole_exp c y) @@ -165,7 +165,7 @@ and exec_boole_exp c = function (* valuta una MathQL.val_exp e ritorna un MathQL.value *) and exec_val_exp c = function - | MathQL.Const x -> let + MathQL.Const x -> let ol = List.sort compare x in let rec edup = function @@ -180,7 +180,7 @@ and exec_val_exp c = function | MathQL.VVar s -> List.assoc s c.vvars | MathQL.RefOf sexp -> List.map (fun (s,_) -> s) (exec_set_exp c sexp) - + | MathQL.Fun (s, vexp) -> fun_ex s (exec_val_exp c vexp) | _ -> assert false