* http://helm.cs.unibo.it/
*)
-open Printf
-
-module DB = Dbi_mysql
+open MetadataTypes
-let sort_tbl = "refSort"
-let rel_tbl = "refRel"
-let obj_tbl = "refObj"
-let owners_tbl = "owners"
-let conclno_tbl = "no_inconcl_aux"
-let conclno_hyp_tbl = "no_concl_hyp"
-let name_tbl = "objectName"
-
-(* let baseuri = "http://www.cs.unibo.it/helm/schemas/schema-helm#" *)
-let baseuri = ""
-let inconcl_uri = baseuri ^ "InConclusion"
-let mainconcl_uri = baseuri ^ "MainConclusion"
-let mainhyp_uri = baseuri ^ "MainHypothesis"
-let inhyp_uri = baseuri ^ "InHypothesis"
-let inbody_uri = baseuri ^ "InBody"
+open Printf
let prepare_insert (dbh: Dbi.connection) =
let insert_owner =
let insert_const_no dbh uri =
let inconcl_no =
sprintf "INSERT INTO %s SELECT \"%s\", COUNT(DISTINCT h_occurrence) FROM %s WHERE (h_position=\"%s\" OR h_position=\"%s\") AND source LIKE \"%s%%\""
- conclno_tbl uri obj_tbl inconcl_uri mainconcl_uri uri
+ conclno_tbl uri obj_tbl inconcl_pos mainconcl_pos uri
in
let concl_hyp =
sprintf "INSERT INTO %s
SELECT \"%s\",COUNT(DISTINCT h_occurrence)
FROM %s
WHERE NOT (h_position=\"%s\") AND (source = \"%s\")"
- conclno_hyp_tbl uri obj_tbl inbody_uri uri
+ conclno_hyp_tbl uri obj_tbl inbody_pos uri
in
(dbh#prepare inconcl_no)#execute [];
(dbh#prepare concl_hyp)#execute []
in
query#execute [];
List.map
- (function [source_col] -> source_col | _ -> assert false)
+ (function [`String source_col] -> source_col | _ -> assert false)
(query#fetchall ())
in
let del_from tbl =
let query =
dbh#prepare (sprintf "DELETE FROM %s WHERE source LIKE \"?%%\"" tbl)
in
- query#execute owned_uris
+ List.iter (fun source_col -> query#execute [`String source_col]) owned_uris
in
List.iter del_from
[sort_tbl; rel_tbl; obj_tbl; conclno_tbl; conclno_hyp_tbl; name_tbl;