Commit 665e0a60 authored by R.W.Majeed's avatar R.W.Majeed

modifier support for ontology processing

parent 78decaaa
......@@ -84,10 +84,11 @@ public interface Concept {
* The part relationship is different from the narrower relationship
* in the sense that {@link #getNarrower()} will point to more specific concepts while
* {@link #getParts()} will divide the concept in the sense of a whole/part relationship.
*
* @param inherited whether to return parts which are inherited from broader concepts.
* @return concepts which are part of this concept, or {@code null} if this concept cannot be divided.
* @throws OntologyException for ontology errors
*/
Concept[] getParts();
Concept[] getParts(boolean inherited) throws OntologyException;
/**
* Get restrictions for the values of this concept.
......
......@@ -26,7 +26,8 @@ public class TestOntologyImport {
props.put("meta.sourcesystem_cd", "test");
props.put("meta.table", "i2b2metadata.i2b2");
props.put("meta.access", "i2b2metadata.table_access");
props.put("data.concept.table", "i2b2crcdata.concepts");
props.put("data.concept.table", "i2b2crcdata.concept_dimension");
props.put("data.concept.table", "i2b2crcdata.modifier_dimension");
props.put("ont.language", "en");
imp = new Import(dbcMeta, dbcData, props);
}
......
......@@ -7,7 +7,7 @@ meta.basepath=\\i2b2\\
meta.sourcesystem_cd=test
data.concept.table=i2b2demodata.concept_dimension
data.modifier.table=i2b2demodata.modifier_dimension
# language to use for accessing ontology
ont.language=DE
......@@ -497,11 +497,18 @@
dwh:restriction dwh:Integer ;
skos:notation "LOINC:9268-4" .
:RightPupil a skos:Concept ;
dwh:isPartOf :Pupilsize ;
skos:prefLabel "Right Pupil"@en ;
skos:prefLabel "Rechte Pupille"@de ;
skos:notation "right".
:Pupilsize a skos:Concept ;
skos:inScheme :EmergencyNote ;
skos:prefLabel "Size of pupil"@en ;
skos:prefLabel "Pupillenweite"@de ;
dwh:hasPart :RightPupil ;
dc:description "Pupillenweite: Auswahlliste" ;
skos:narrower :dilated ;
......
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dwh: <http://sekmi.de/histream/dwh#> .
@prefix : <http://sekmi.de/histream/skos/tests#> .
: dc:title "HIStream concept ontology for testing".
:TestScheme a skos:ConceptScheme ;
skos:hasTopConcept :TestData .
:TestData a skos:Concept ;
skos:prefLabel "TestData_label_en"@en ;
skos:prefLabel "TestData_label_de"@de ;
skos:narrower :TestStringConcept ;
skos:narrower :TestIntegerConcept ;
skos:narrower :TestDecimalConcept ;
skos:narrower :TestEnumConcept ;
dc:description "Top concept for test data" .
:TestEnumConcept a skos:Concept;
skos:inScheme :TestData;
dwh:restriction [ a owl:Restriction ;
owl:onProperty rdf:value;
owl:oneOf (
[rdf:value "1"^^xsd:string; skos:prefLabel "1_de"@de; skos:prefLabel "1_en"@en ]
[rdf:value "2"^^xsd:string; skos:prefLabel "2_de"@de; skos:prefLabel "2_en"@en ]
)
] ;
skos:prefLabel "Enum_label_de"@de;
skos:prefLabel "Enum_label_en"@en;
skos:notation "T:Enum" .
####### skos:notation "Enum"^^:TestCS .
dwh:Integer a owl:Restriction ;
owl:onProperty rdf:value ;
owl:allValuesFrom xsd:integer .
dwh:String a owl:Restriction ;
owl:onProperty rdf:value ;
owl:allValuesFrom xsd:string .
:TestIntegerConcept a skos:Concept;
skos:inScheme :TestData ;
dwh:restriction dwh:Integer ;
skos:prefLabel "Integer_label_en"@en ;
skos:prefLabel "Integer_label_de"@de ;
dc:description "Description_de"@de ;
dc:description "Description_neutral" ;
skos:notation "T:type:int" .
:TestStringConcept a skos:Concept;
skos:inScheme :TestData ;
dwh:restriction dwh:String ;
skos:prefLabel "String_label_en"@en ;
skos:notation "T:type:str" .
:TestDecimalConcept a skos:Concept;
skos:inScheme :TestData ;
dwh:restriction [ a owl:Restriction ;
owl:onProperty rdf:value ;
owl:allValuesFrom[ a rdfs:Datatype;
owl:onDatatype xsd:decimal;
owl:withRestrictions(
[ xsd:minInclusive 200 ]
[ xsd:maxInclusive 400 ]
)
]
] ;
skos:prefLabel "Decimal_label_en"@en ;
skos:notation "T:type:dec" .
# Test inferred topConcept and narrower
:OtherScheme a skos:ConceptScheme .
:OtherTop a skos:Concept ;
skos:inScheme :OtherScheme ;
skos:topConceptOf :OtherScheme ;
skos:prefLabel "OtherTop_label_en"@en .
:OtherSub a skos:Concept ;
skos:inScheme :OtherScheme ;
skos:inScheme :TestScheme ;
skos:broader :OtherTop ;
skos:prefLabel "OtherSub_label_en"@en ;
skos:notation "other" .
# Second dimension / modifiers
:Mod1 a skos:Concept ;
dwh:isPartOf :TestData ;
skos:prefLabel "Mod1 en"@en ;
skos:notation "m1" .
\ No newline at end of file
......@@ -88,3 +88,9 @@ dwh:String a owl:Restriction ;
skos:broader :OtherTop ;
skos:prefLabel "OtherSub_label_en"@en ;
skos:notation "other" .
# Second dimension / modifiers
:Mod1 a skos:Concept ;
dwh:isPartOf :TestData ;
skos:prefLabel "Mod1 en"@en ;
skos:notation "m1" .
\ No newline at end of file
......@@ -89,9 +89,8 @@ public class ConceptImpl implements Concept {
}
@Override
public Concept[] getParts() {
// TODO implement
return null;
public Concept[] getParts(boolean inherited) throws OntologyException {
return store.getParts(this, inherited);
}
@Override
......
......@@ -16,6 +16,8 @@ public class HIStreamOntology {
public static final URI DWH_OTHERWISE;
public static final URI DWH_XPATH;
public static final URI DWH_ECMASCRIPT;
public static final URI DWH_HAS_PART;
public static final URI DWH_IS_PART_OF;
static {
final ValueFactory f = ValueFactoryImpl.getInstance();
......@@ -28,6 +30,8 @@ public class HIStreamOntology {
DWH_OTHERWISE = f.createURI(DWH_NAMESPACE, "otherwise");
DWH_XPATH = f.createURI(DWH_NAMESPACE, "XPath");
DWH_ECMASCRIPT = f.createURI(DWH_NAMESPACE, "ECMAScript");
DWH_HAS_PART = f.createURI(DWH_NAMESPACE, "hasPart"); // TODO use correct names/URIs
DWH_IS_PART_OF = f.createURI(DWH_NAMESPACE, "isPartOf"); // XXX see above
}
}
......@@ -6,6 +6,7 @@ import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
......@@ -48,6 +49,8 @@ public class Store implements Ontology, Plugin {
private Resource inferredContext;
// SKOS scheme to enforce unique notations
private Resource scheme;
private Map<String, String> namespaceShortener;
/// XXX namespace resolver
/**
* Plugin constructor which accepts configuration parameters.
......@@ -139,6 +142,7 @@ public class Store implements Ontology, Plugin {
return count;
}
private void initializeRepo(Iterable<File> files, Iterable<URL> urls, String baseURI) throws RepositoryException, IOException{
namespaceShortener = new HashMap<>();
repo = new SailRepository(new MemoryStore());
repo.initialize();
rc = repo.getConnection();
......@@ -171,6 +175,7 @@ public class Store implements Ontology, Plugin {
inferred += inferInverseRelations(SKOS.TOP_CONCEPT_OF, SKOS.HAS_TOP_CONCEPT);
inferred += inferInverseRelations(SKOS.BROADER, SKOS.NARROWER);
inferred += inferInverseRelations(SKOS.NARROWER, SKOS.BROADER);
// TODO a isPartOf b -> b hasPart a
if( inferred != 0 ){
log.fine("Inferred "+inferred+" statements.");
}
......@@ -230,6 +235,9 @@ public class Store implements Ontology, Plugin {
Concept[] getNarrower(ConceptImpl concept)throws OntologyException{
return getRelatedConcepts(concept.getResource(), SKOS.NARROWER);
}
Concept[] getParts(ConceptImpl concept, boolean inherited)throws OntologyException{
return getRelatedConcepts(concept.getResource(), HIStreamOntology.DWH_HAS_PART);
}
public void printTopConcepts() throws OntologyException{
for( Concept c : getTopConcepts() ){
......
......@@ -13,6 +13,7 @@ import de.sekmi.histream.ontology.Concept;
import de.sekmi.histream.ontology.OntologyException;
import de.sekmi.histream.ontology.ValueRestriction;
import de.sekmi.histream.ontology.skos.Store;
import de.sekmi.histream.xml.NamespaceResolver;
public class OntologyTest {
Store store;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment