package rdf

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file rdfs.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
(*********************************************************************************)
(*                OCaml-RDF                                                      *)
(*                                                                               *)
(*    Copyright (C) 2012-2024 Institut National de Recherche en Informatique     *)
(*    et en Automatique. All rights reserved.                                    *)
(*                                                                               *)
(*    This program is free software; you can redistribute it and/or modify       *)
(*    it under the terms of the GNU Lesser General Public License version        *)
(*    3 as published by the Free Software Foundation.                            *)
(*                                                                               *)
(*    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., 59 Temple Place, Suite 330, Boston, MA                   *)
(*    02111-1307  USA                                                            *)
(*                                                                               *)
(*    Contact: Maxence.Guesdon@inria.fr                                          *)
(*                                                                               *)
(*********************************************************************************)

let rdfs_str = "http://www.w3.org/2000/01/rdf-schema#";;
let rdfs = Iri.of_string rdfs_str ;;
let rdfs_ s = Iri.of_string (rdfs_str ^ s);;

let c_Class = rdfs_ "Class" ;;
let comment = rdfs_ "comment" ;;
let c_Container = rdfs_ "Container" ;;
let c_ContainerMembershipProperty = rdfs_ "ContainerMembershipProperty" ;;
let c_Datatype = rdfs_ "Datatype" ;;
let domain = rdfs_ "domain" ;;
let isDefinedBy = rdfs_ "isDefinedBy" ;;
let label = rdfs_ "label" ;;
let c_Literal = rdfs_ "Literal" ;;
let member = rdfs_ "member" ;;
let range = rdfs_ "range" ;;
let c_Resource = rdfs_ "Resource" ;;
let seeAlso = rdfs_ "seeAlso" ;;
let subClassOf = rdfs_ "subClassOf" ;;
let subPropertyOf = rdfs_ "subPropertyOf" ;;

module Open = struct
  let rdfs_c_Class = c_Class
  let rdfs_comment = comment
  let rdfs_c_Container = c_Container
  let rdfs_c_ContainerMembershipProperty = c_ContainerMembershipProperty
  let rdfs_c_Datatype = c_Datatype
  let rdfs_domain = domain
  let rdfs_isDefinedBy = isDefinedBy
  let rdfs_label = label
  let rdfs_c_Literal = c_Literal
  let rdfs_member = member
  let rdfs_range = range
  let rdfs_c_Resource = c_Resource
  let rdfs_seeAlso = seeAlso
  let rdfs_subClassOf = subClassOf
  let rdfs_subPropertyOf = subPropertyOf
end

let add_label g iri ?lang s =
  let obj = Term.term_of_literal_string ?lang s in
  g.Graph.add_triple
    ~sub: (Term.Iri iri)
    ~pred: label
    ~obj
;;

let add_comment g iri ?lang s =
let obj = Term.term_of_literal_string ?lang s in
  g.Graph.add_triple
    ~sub: (Term.Iri iri)
    ~pred: comment
    ~obj
;;

let add_domain g iri dom =
  g.Graph.add_triple
    ~sub: (Term.Iri iri)
    ~pred: domain
    ~obj: (Term.Iri dom)
;;

let add_range g iri dom =
  g.Graph.add_triple
    ~sub: (Term.Iri iri)
    ~pred: range
    ~obj: (Term.Iri dom)
;;

let add_more g iri (pred, obj) =
  g.Graph.add_triple ~sub: (Term.Iri iri) ~pred ~obj
;;

let mk_property g ~label ?(label_lang=[]) ?comment ?(comment_lang=[])
  ?(domains=[]) ?(ranges=[]) ?subof ?(more=[]) iri =
  g.Graph.add_triple ~sub: (Term.Iri iri)
    ~pred: Rdf_.type_ ~obj: (Term.Iri Rdf_.c_Property);
  add_label g iri label ;
  List.iter (fun (s, lang) -> add_label g iri ~lang s) label_lang;
  (match comment with None -> () | Some s -> add_comment g iri s);
  List.iter (fun (s, lang) -> add_comment g iri ~lang s) comment_lang;
  List.iter (add_domain g iri) domains ;
  List.iter (add_range g iri) ranges ;
  (match subof with
    None -> ()
  | Some cl ->
       g.Graph.add_triple ~sub: (Term.Iri iri)
         ~pred: subPropertyOf ~obj: (Term.Iri cl)
  );
  List.iter (add_more g iri) more
;;

let mk_class g ~label ?(label_lang=[]) ?comment ?(comment_lang=[])
   ?subof ?(more=[]) iri =
  g.Graph.add_triple ~sub: (Term.Iri iri)
    ~pred: Rdf_.type_ ~obj: (Term.Iri c_Class);
  add_label g iri label ;
  List.iter (fun (s, lang) -> add_label g iri ~lang s) label_lang;
  (match comment with None -> () | Some s -> add_comment g iri s);
  List.iter (fun (s, lang) -> add_comment g iri ~lang s) comment_lang;
  (match subof with
    None -> ()
  | Some cl ->
       g.Graph.add_triple ~sub: (Term.Iri iri)
         ~pred: subClassOf ~obj: (Term.Iri cl)
  );
  List.iter (add_more g iri) more
;;

let add_namespaces g =
  g.Graph.add_namespace Rdf_.rdf "rdf" ;
  g.Graph.add_namespace rdfs "rdfs"
;;
OCaml

Innovation. Community. Security.