Init wiki from unsel-data wiki authored by Aurélien Lamercerie's avatar Aurélien Lamercerie
Cette page donne quelques exemples d'extraction simple en s'appuyant sur les phrases suivantes :
R1 : The system allows a radio channel to take on two states : listening and trafic
![graph_1_.svg](uploads/56613fef6f4611346b6f5b16442b3fe0/graph_1_.svg)
R2 : The system displays a channel in green when it is in broadcast state
![graph.svg](uploads/82aa23ead12c6b4f42d057a92794e74d/graph.svg)
Le fichier rdf-unl qui contient ces phrases (:bangbang: Il importe le schéma `https://unl.tetras-libre.fr/rdf/schema#` qui doit être acceessible dans le workspace) :
[2_exemple-rdf-unl-automatic-unl2rdf.ttl](uploads/731a7c5b3f8317a7c4893e0b64e8532c/2_exemple-rdf-unl-automatic-unl2rdf.ttl)
# Règle 1 : extraction d'une cardinalité
Typiquement ce genre de sous-graphe :
![image](uploads/3ac719d13bc916e993ed306a94c2b9f2/image.png)
```sparql
CONSTRUCT {?lex owl:cardinality ?tInt }
WHERE {
?this a unl:qua ;
unl:has_source ?s ;
unl:has_target ?t .
?t rdfs:label ?tLabel .
?s unl:is_occurrence_of ?lex
BIND(xsd:integer(?tLabel) AS ?tInt)
}
```
# Règle 2 : extraction d'une énumération à deux éléments (1 x `and`)
Typiquement ce genre de sous-graphe :
![image](uploads/212110a7d28e7ea536d974dfc02c663f/image.png)
```sparql
CONSTRUCT {
?lex owl:equivalentClass [
rdf:type rdfs:Datatype ;
owl:oneOf (?l1 ?l2)
]
}
WHERE {
?this a unl:cnt ;
unl:has_source ?s ;
unl:has_target ?t1 .
?s unl:is_occurrence_of ?lex .
?lex rdfs:label ?label .
FILTER regex(?label,"icl>attribute")
?and1 a unl:and ;
unl:has_source ?t1 ;
unl:has_target ?t2 .
?t1 rdfs:label ?l1 .
?t2 rdfs:label ?l2 .
}
```
# Règle 3 : extraction d'une datatype property à partir d'une UW avec `icl>be` dans ses restrictions
Typiquement ce genre de sous-graphe (sans l'arc `mod`):
![image](uploads/56b8e205e6e7be3abfabae22e0f9cc1b/image.png)
Note : on extrait aussi le domaine et le but de la relation (`domain` et `range`)
```sparql
CONSTRUCT {
?lex a owl:DatatypeProperty ;
rdfs:domain ?slex ;
rdfs:range ?tlex .
?slex a owl:Class .
?tlex a rdfs:Datatype .
}
WHERE {
?this unl:is_occurrence_of ?lex .
?lex rdfs:label ?label .
FILTER regex(str(?label),"icl>be")
?this unl:aoj ?s .
?this unl:obj ?t .
?s unl:is_occurrence_of ?slex .
?t unl:is_occurrence_of ?tlex .
?tlex rdfs:label ?tlabel .
FILTER regex(str(?tlabel),"icl>attribute")
}
```
# Règle 4 : instanciation d'une datatype property précédement créée
Typiquement ce genre de sous-graphe (avec un arc `plc` au lieu de `mod`):
![image](uploads/56b8e205e6e7be3abfabae22e0f9cc1b/image.png)
```sparql
CONSTRUCT {
?aoj a ?aojLex ;
?lex ?modLabel
}
WHERE {
?this rdfs:label ?label .
FILTER regex(str(?label),"icl>be")
?this unl:aoj ?aoj ;
unl:obj ?obj ;
unl:is_occurrence_of ?lex .
?aoj unl:has_attribute ".@indef" ; unl:is_occurrence_of ?aojLex .
?obj unl:plc ?mod ; rdfs:label ?objLabel .
FILTER regex(?objLabel,"icl>attribute")
?mod rdfs:label ?modLabel .
}
```
todo : faire une requête qui fonctionne avec toutes les "sous-relations" de `mod` en interrogeant le schéma unl-rdf
\ No newline at end of file