-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlink-cdtb.sparql
95 lines (80 loc) · 4.03 KB
/
link-cdtb.sparql
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
# annotate native and and closest OLiA senses
PREFIX dimlex: <https://github.com/discourse-lab/dimlex/blob/master/DimLex.dtd#>
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
PREFIX cdtb: <http://purl.org/olia/discourse/discourse.CDTB.owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX olia: <http://purl.org/olia/discourse/olia_discourse.owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
# annotate native
#LOAD <http://purl.org/olia/discourse/discourse.CDTB.owl>;
LOAD <file:///home/chiarcos/Desktop/github/olia/owl/experimental/discourse/discourse.CDTB.owl>;
INSERT {
?dimlex_relation ontolex:reference ?cdtb_sense.
} WHERE {
?dimlex_relation dimlex:sense ?label.
?cdtb_sense (rdfs:label|skos:altLabel) ?sense_label.
FILTER(lcase(?label)=lcase(?sense_label))
};
# map to OLiA
#LOAD <http://purl.org/olia/discourse/discourse.CDTB-link.rdf>;
LOAD <file:///home/chiarcos/Desktop/github/olia/owl/experimental/discourse/discourse.CDTB-link.rdf>;
INSERT {
?dimlex ontolex:reference ?olia_sense.
} WHERE {
?dimlex ontolex:reference ?cdtb_sense.
{ SELECT ?cdtb_sense (MIN(?distance) as ?minDistance)
{ SELECT ?cdtb_sense ?olia_sense (COUNT(distinct ?step) as ?distance)
WHERE {
?cdtb_sense (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)+ ?step.
?step (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)* ?olia_sense.
FILTER(strstarts(str(?olia_sense), "http://purl.org/olia/discourse/olia_discourse.owl"))
} GROUP BY ?cdtb_sense ?olia_sense
} GROUP BY ?cdtb_sense
}
{ SELECT ?cdtb_sense ?olia_sense (COUNT(distinct ?step) as ?distance)
WHERE {
?cdtb_sense (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)+ ?step.
?step (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)* ?olia_sense.
FILTER(strstarts(str(?olia_sense), "http://purl.org/olia/discourse/olia_discourse.owl"))
} GROUP BY ?cdtb_sense ?olia_sense
}
FILTER(?distance=?minDistance)
};
# map to PDTB (but only if these are proper subclasses)
#LOAD <http://purl.org/olia/discourse/discourse.PDTB-link.rdf>;
LOAD <file:///home/chiarcos/Desktop/github/olia/owl/experimental/discourse/discourse.PDTB-link.rdf>;
INSERT {
?dimlex ontolex:reference ?pdtb_sense.
} WHERE {
?dimlex ontolex:reference ?olia_sense.
{ SELECT ?pdtb_sense (MIN(?distance) as ?minDistance)
{ SELECT ?pdtb_sense ?olia_sense (COUNT(distinct ?step) as ?distance)
WHERE {
?pdtb_sense (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)+ ?step.
?step (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)* ?olia_sense.
FILTER(strstarts(str(?olia_sense), "http://purl.org/olia/discourse/olia_discourse.owl"))
} GROUP BY ?pdtb_sense ?olia_sense
} GROUP BY ?pdtb_sense
}
{ SELECT ?pdtb_sense ?olia_sense (COUNT(distinct ?step) as ?distance)
WHERE {
?pdtb_sense (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)+ ?step.
?step (rdfs:subClassOf|owl:sameAs|owl:equivalentClass|(rdf:rest*/rdf:first)|owl:intersectionOf|owl:join)* ?olia_sense.
FILTER(strstarts(str(?olia_sense), "http://purl.org/olia/discourse/olia_discourse.owl"))
} GROUP BY ?pdtb_sense ?olia_sense
}
FILTER(?distance=?minDistance)
};
MOVE DEFAULT TO <http://placehold.er>;
# keep ontolex core information only
INSERT {
?a ?b ?c
} WHERE {
GRAPH <http://placehold.er> {
?a ?b ?c
FILTER(strstarts(str(?b),'http://www.w3.org/ns/lemon/ontolex#') || strstarts(str(?c),'http://www.w3.org/ns/lemon/ontolex#'))
}
};
DROP GRAPH <http://placehold.er>