Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 2cdb6919 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- Implemented skosapi as HeavyLoadedOntology

- suppressed comments
parent c112dce1
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ public class StringDistAlignment extends DistanceAlignment implements AlignmentP
// Unnamed entity = max distance
if ( s1 == null || s2 == null ) return 1.;
Object[] params = { s1.toLowerCase(), s2.toLowerCase() };
//if ( debug > 4 )
if ( debug > 4 )
System.err.println( "OB:"+s1+" ++ "+s2+" ==> "+dissimilarity.invoke( null, params ));
return ((Double)dissimilarity.invoke( null, params )).doubleValue();
}
......
......@@ -38,12 +38,13 @@ public class SKOSOntologyFactory extends OntologyFactory {
private static URI formalismUri = null;
private static String formalismId = "SKOS1.0";
private static OntologyCache<SKOSOntology> cache = null;
private static OntologyCache<SKOSThesaurus> cache = null;
private SKOSManager manager;
private SKOSDataFactory factory;
public SKOSOntologyFactory() throws OntowrapException {
cache = new OntologyCache<SKOSThesaurus>();
try {
formalismUri = new URI("http://www.w3.org/2004/02/skos/core#");
} catch (URISyntaxException ex) { ex.printStackTrace(); } // should not happen
......@@ -56,10 +57,10 @@ public class SKOSOntologyFactory extends OntologyFactory {
}
@Override
public SKOSOntology newOntology( Object ontology ) throws OntowrapException {
public SKOSThesaurus newOntology( Object ontology ) throws OntowrapException {
if ( ontology instanceof SKOSDataset ) {
SKOSOntology onto = null;
onto = new SKOSOntology();
SKOSThesaurus onto = null;
onto = new SKOSThesaurus();
onto.setFormalism( formalismId );
onto.setFormURI( formalismUri );
onto.setOntology( (SKOSDataset)ontology );
......@@ -75,8 +76,9 @@ public class SKOSOntologyFactory extends OntologyFactory {
}
@Override
public SKOSOntology loadOntology( URI uri ) throws OntowrapException {
SKOSOntology onto = null;
public SKOSThesaurus loadOntology( URI uri ) throws OntowrapException {
//System.err.println(" Loading "+uri );
SKOSThesaurus onto = null;
onto = cache.getOntologyFromURI( uri );
if ( onto != null ) return onto;
onto = cache.getOntology( uri );
......@@ -87,7 +89,7 @@ public class SKOSOntologyFactory extends OntologyFactory {
} catch (SKOSCreationException sce) {
throw new OntowrapException( "Cannot load ontology: "+uri, sce);
}
onto = new SKOSOntology();
onto = new SKOSThesaurus();
onto.setFormalism( formalismId );
onto.setFormURI( formalismUri );
onto.setOntology( dataset );
......@@ -95,12 +97,13 @@ public class SKOSOntologyFactory extends OntologyFactory {
onto.setFile( uri );
// This is the URI of the corresponding OWL API Ontology
onto.setURI( dataset.getURI() );
cache.recordOntology( uri, onto );
//cache.recordOntology( uri, onto );
return onto;
}
@Override
public void clearCache() {
public void clearCache() throws OntowrapException {
cache.clear();
}
......
......@@ -36,14 +36,17 @@ import org.semanticweb.skos.SKOSUntypedLiteral;
import org.semanticweb.skos.SKOSDataProperty;
import fr.inrialpes.exmo.ontowrap.BasicOntology;
import fr.inrialpes.exmo.ontowrap.LoadedOntology;
import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology;
import fr.inrialpes.exmo.ontowrap.OntowrapException;
public class SKOSOntology extends BasicOntology<SKOSDataset> implements LoadedOntology<SKOSDataset>{
public class SKOSThesaurus extends BasicOntology<SKOSDataset> implements HeavyLoadedOntology<SKOSDataset>{
SKOSDataFactory factory;
public SKOSOntology () {
private static HashSet NullSet = new HashSet();
public SKOSThesaurus () {
NullSet = new HashSet();
}
public void setFactory( SKOSDataFactory df ){
......@@ -82,7 +85,7 @@ lang = untypedLiteral.getLang();
public void getDataValues( SKOSConcept o, SKOSDataProperty p, Set<String> result ){
for ( SKOSLiteral lit : onto.getSKOSDataRelationByProperty( o, p ) ){
result.add( lit.toString() );
result.add( lit.getLiteral() );
}
}
......@@ -91,8 +94,8 @@ lang = untypedLiteral.getLang();
if ( !lit.isTyped() ) {
SKOSUntypedLiteral l = lit.getAsSKOSUntypedLiteral();
if ( l.hasLang() && l.getLang().equals( lang ) )
result.add( lit.toString() );
}
result.add( lit.getLiteral() );
} // JE: what if typed?
}
}
......@@ -255,7 +258,8 @@ lang = untypedLiteral.getLang();
//@SuppressWarnings("unchecked")
public Set<?> getDataProperties() {
return null; // null or new HashSet()
return NullSet;
// return null; // null or new HashSet()
}
//@SuppressWarnings("unchecked")
......@@ -265,17 +269,17 @@ lang = untypedLiteral.getLang();
//@SuppressWarnings("unchecked")
public Set<?> getIndividuals() {
return null;
return NullSet;
}
//@SuppressWarnings("unchecked")
public Set<?> getObjectProperties() {
return null;
return NullSet;
}
//@SuppressWarnings("unchecked")
public Set<?> getProperties() {
return null;
return NullSet;
}
public boolean isClass(Object o) {
......@@ -335,5 +339,53 @@ lang = untypedLiteral.getLang();
o.getSKOSNarrowerConcepts( onto )
o.getSKOSNarrowerTransitiveConcepts( onto )
**/
/* Capability methods */
// TODO
public boolean getCapabilities( int Direct, int Asserted, int Named ) {
return false;
}
/* Class methods */
public Set<Object> getSubClasses( Object c, int local, int asserted, int named ) {
// TODO
return NullSet;
}
public Set<Object> getSuperClasses( Object c, int local, int asserted, int named ){
// TODO
return NullSet;
}
public Set<Object> getProperties( Object c, int local, int asserted, int named ){
return NullSet;
}
public Set<Object> getDataProperties( Object c, int local, int asserted, int named ){
return NullSet;
}
public Set<Object> getObjectProperties( Object c, int local, int asserted, int named ){
return NullSet;
}
public Set<Object> getInstances( Object c, int local, int asserted, int named ){
return NullSet;
}
/* Property methods */
public Set<Object> getSubProperties( Object p, int local, int asserted, int named ){
return NullSet;
}
public Set<Object> getSuperProperties( Object p, int local, int asserted, int named ){
return NullSet;
}
public Set<Object> getRange( Object p, int asserted ){
return NullSet;
}
public Set<Object> getDomain( Object p, int asserted ){
return NullSet;
}
/* Individual methods */
public Set<Object> getClasses( Object i, int local, int asserted, int named ){
return NullSet;
//return onto.getSKOSConcepts();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment