-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ml
79 lines (65 loc) · 1.99 KB
/
types.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(**********
OWL
**********)
type owl_type_base =
| Int
| String
type owl_class =
| Class of string
type owl_property =
| ObjectProperty of string * string * string
| DatatypeProperty of string * string * owl_type_base
type owl_ontology =
| Ontology of string * string
type owl_data_property =
| DataObjectProperty of string * string
| DataDatatypeProperty of string * string
type owl_data_instance =
| DataInstance of string * string * owl_data_property list
(**********
SQL
**********)
type sql_type =
| Varchar of int
| Number of int
| Char of int
type sql_option =
| NotNull
| PrimaryKey
| References of string * string
type sql_field =
| Field of string * sql_type * sql_option list
type sql_table =
| Table of string * sql_field list
(* Owl -> String *)
let string_of_owl_base_type = function
| Int -> "int"
| String -> "string"
let string_of_owl_class = function
| Class s ->
"<owl:Class rdf:about=\"#" ^ s ^ "\" />\n"
let string_of_owl_property = function
| ObjectProperty (name, domain, range) ->
"<owl:ObjectProperty rdf:about=\"#" ^ name ^ "\">" ^
"<rdfs:domain rdf:resource=\"#" ^ domain ^ "\" />" ^
"<rdfs:range rdf:resource=\"#" ^ range ^ "\" />" ^
"</owl:ObjectProperty>\n"
| DatatypeProperty (name, domain, range) ->
"<owl:DatatypeProperty rdf:about=\"#" ^ name ^ "\">" ^
"<rdfs:domain rdf:resource=\"#" ^ domain ^ "\" />" ^
"<rdfs:range rdf:resource=\"" ^ (string_of_owl_base_type range) ^
"\" />" ^
"</owl:DatatypeProperty>\n"
let string_of_owl_data_property = function
| DataObjectProperty (tag, data) ->
"<" ^ tag ^ " rdf:resource=\"#" ^ data ^ "\" />\n"
| DataDatatypeProperty (tag, data) ->
"<" ^ tag ^ ">" ^ data ^ "</" ^ tag ^ ">\n"
let string_of_owl_data_instance = function
| DataInstance (tag, about, properties) ->
"<" ^ tag ^ " rdf:about=\"#" ^ about ^ "\">\n" ^
(List.fold_left
(fun a b -> a ^ (string_of_owl_data_property b))
""
properties) ^
"</" ^ tag ^ ">\n"