This repository has been archived by the owner on Jun 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extended the indexing process with a simple word-sense disambiguation
mechanism for enabling semantic expansion of the queries performed over the ontology indexes.
- Loading branch information
1 parent
ed92878
commit 0942d1a
Showing
7 changed files
with
362 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/api/src/main/java/it/cnr/istc/stlab/ontonethub/NoSuchOntologyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package it.cnr.istc.stlab.ontonethub; | ||
|
||
/** | ||
* | ||
* @author Andrea Nuzzolese (https://github.com/anuzzolese) | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class NoSuchOntologyException extends Exception { | ||
|
||
private String ontologyID; | ||
|
||
public NoSuchOntologyException(String ontologyID) { | ||
this.ontologyID = ontologyID; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return "No ontology with ID " + ontologyID + " exists."; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/api/src/main/java/it/cnr/istc/stlab/ontonethub/OntoNetHub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package it.cnr.istc.stlab.ontonethub; | ||
|
||
import org.apache.stanbol.commons.jobs.api.Job; | ||
import org.apache.stanbol.entityhub.servicesapi.Entityhub; | ||
import org.apache.stanbol.entityhub.servicesapi.site.ManagedSite; | ||
|
||
import com.hp.hpl.jena.rdf.model.Model; | ||
|
||
import it.cnr.istc.stlab.ontonethub.job.IndexingJobInput; | ||
|
||
/** | ||
* Public interface for the OntoNetHub.<br> | ||
* It declares the core methods that implements CRUD operations on the ontology index. | ||
* | ||
* | ||
* @author Andrea Nuzzolese (https://github.com/anuzzolese) | ||
* | ||
*/ | ||
public interface OntoNetHub { | ||
|
||
/** | ||
* The method creates an index for the ontology provided as input inside the object instance of the class {@link IndexingJobInput}. | ||
* The index is generated as an OSGi bundle and loaded to the Felix environment as a {@link ManagedSite} of the {@link Entityhub}. | ||
* The index is created by running an indexing job, which is a instance of a {@link Job}. | ||
* | ||
* @param input | ||
* @return the String identifying the indexing job. | ||
* @throws OntologyAlreadyExistingException | ||
*/ | ||
String indexOntology(IndexingJobInput input) throws OntologyAlreadyExistingException; | ||
|
||
/** | ||
* The method return the source of the ontology identified by the ID provided as input. | ||
* | ||
* @param id | ||
* @return the ontology as a Jena {@link Model} | ||
* @throws NoSuchOntologyException | ||
*/ | ||
Model getOntologySource(String id) throws NoSuchOntologyException; | ||
|
||
/** | ||
* The method returns all the metadata associated with an ontology within the index. | ||
* Namely, those metadata are: | ||
* <ul> | ||
* <li><b>ontologyID</b>: the identifier of the ontology in the OntoNetHub;</li> | ||
* <li><b>ontologySource</b>: the URL of the service that serves the ontology source;</li> | ||
* <li><b>ontologyName</b>: the name of the ontology;</li> | ||
* <li><b>ontologyDescription</b>: a human-readable description of the ontology;</li> | ||
* <li><b>ontologyIRI</b>: the IRI associated with the ontology (i.e. the official location in the Web where the ontology is available);</li> | ||
* <li><b>owlClasses</b>: the number of the OWL classes available in the ontology;</li> | ||
* <li><b>objectProperties</b>: the number of the OWL object properties available in the ontology;</li> | ||
* <li><b>datatypeProperties</b>: the number of the OWL datatype properties available in the ontology;</li> | ||
* <li><b>annotationProperties</b>: the number of the OWL annotation properties available in the ontology;</li> | ||
* <li><b>annotationProperties</b>: the number of the OWL individuals available in the ontology;</li> | ||
* <li><b>importedOntologies</b>: the number of the ontology imported by ontology by means of owl:import axioms;</li> | ||
* </ul> | ||
* | ||
* @param id | ||
* @return | ||
* @throws NoSuchOntologyException | ||
*/ | ||
OntologyInfo getOntologyInfo(String id) throws NoSuchOntologyException; | ||
|
||
/** | ||
* The method returns all the metadata associated with the ontologies available in the index. | ||
* | ||
* @return | ||
* @throws NoSuchOntologyException | ||
*/ | ||
OntologyInfo[] getOntologiesInfo(); | ||
|
||
/** | ||
* The method allows developers to delete ontology from the OntoNetHub. | ||
* | ||
* @param id | ||
* @throws UnmappableOntologyException | ||
* @throws NoSuchOntologyException | ||
*/ | ||
void deleteOntologyIndex(String id) throws UnmappableOntologyException, NoSuchOntologyException; | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/api/src/main/java/it/cnr/istc/stlab/ontonethub/OntologyAlreadyExistingException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package it.cnr.istc.stlab.ontonethub; | ||
|
||
/** | ||
* | ||
* @author Andrea Nuzzolese (https://github.com/anuzzolese) | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class OntologyAlreadyExistingException extends Exception { | ||
|
||
private String ontologyName; | ||
|
||
public OntologyAlreadyExistingException(String ontologyName) { | ||
this.ontologyName = ontologyName; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return "The ontology " + ontologyName + " is already managed by the OntoNetHub"; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/api/src/main/java/it/cnr/istc/stlab/ontonethub/OntologyDescriptionVocabulary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package it.cnr.istc.stlab.ontonethub; | ||
|
||
import com.hp.hpl.jena.rdf.model.Property; | ||
import com.hp.hpl.jena.rdf.model.ResourceFactory; | ||
|
||
/** | ||
* | ||
* @author Andrea Nuzzolese (https://github.com/anuzzolese) | ||
* | ||
*/ | ||
public class OntologyDescriptionVocabulary { | ||
|
||
public static String NS = "http://dati.gov.it/onto/ann-voc/"; | ||
|
||
public static String ONTOLOGY = NS + "ontology/"; | ||
public static String DAF_LABEL = NS + "dafLabel"; | ||
public static String DAF_ID = NS + "dafId"; | ||
public static String DEFINED_IN_ONTOLOGY = NS + "definedInOntology"; | ||
public static String DOMAIN_CLASS_LABEL = NS + "domainClassLabel"; | ||
public static String DOMAIN_CLASS_COMMENT = NS + "domainClassComment"; | ||
public static String ONTOLOGY_LABEL = NS + "ontologyLabel"; | ||
public static String ONTOLOGY_COMMENT = NS + "ontologyComment"; | ||
public static String HAS_BUNDLE = NS + "hasBundle"; | ||
public static String HAS_ONTOLOGY_IRI = NS + "hasOntologyIRI"; | ||
public static String HAS_ONTOLOGY_SOURCE = NS + "hasOntologySource"; | ||
public static String OWL_CLASSES = NS + "owlClasses"; | ||
public static String OBJECT_PROPERTIES = NS + "objectProperties"; | ||
public static String DATATYPE_PROPERTIES = NS + "datatypeProperties"; | ||
public static String ANNOTATION_PROPERTIES = NS + "annotationProperties"; | ||
public static String INDIVIDUALS = NS + "individuals"; | ||
public static String IMPORTED_ONTOLOGIES = NS + "importedOntologies"; | ||
public static String SYNONYM = NS + "synonym"; | ||
|
||
public static Property domainClassLabel = ResourceFactory.createProperty(DOMAIN_CLASS_LABEL); | ||
public static Property domainClassComment = ResourceFactory.createProperty(DOMAIN_CLASS_COMMENT); | ||
public static Property ontologyLabel = ResourceFactory.createProperty(ONTOLOGY_LABEL); | ||
public static Property ontologyComment = ResourceFactory.createProperty(ONTOLOGY_COMMENT); | ||
public static Property synonym = ResourceFactory.createProperty(SYNONYM); | ||
|
||
} |
99 changes: 99 additions & 0 deletions
99
src/api/src/main/java/it/cnr/istc/stlab/ontonethub/OntologyInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package it.cnr.istc.stlab.ontonethub; | ||
|
||
/** | ||
* | ||
* @author Andrea Nuzzolese (https://github.com/anuzzolese) | ||
* | ||
*/ | ||
public class OntologyInfo { | ||
|
||
private String ontologyID; | ||
private String ontologySource; | ||
private String ontologyName; | ||
private String ontologyDescription; | ||
private String ontologyIRI; | ||
private int owlClasses; | ||
private int objectProperties; | ||
private int datatypeProperties; | ||
private int annotationProperties; | ||
private int individuals; | ||
private int importedOntologies; | ||
|
||
public OntologyInfo() { | ||
|
||
} | ||
|
||
|
||
public String getOntologyID() { | ||
return ontologyID; | ||
} | ||
|
||
public void setOntologyID(String ontologyID) { | ||
this.ontologyID = ontologyID; | ||
} | ||
|
||
public String getOntologySource() { | ||
return ontologySource; | ||
} | ||
|
||
public void setOntologySource(String ontologySource) { | ||
this.ontologySource = ontologySource; | ||
} | ||
|
||
public String getOntologyName() { | ||
return ontologyName; | ||
} | ||
public void setOntologyName(String ontologyName) { | ||
this.ontologyName = ontologyName; | ||
} | ||
public String getOntologyDescription() { | ||
return ontologyDescription; | ||
} | ||
public void setOntologyDescription(String ontologyDescription) { | ||
this.ontologyDescription = ontologyDescription; | ||
} | ||
public String getOntologyIRI() { | ||
return ontologyIRI; | ||
} | ||
public void setOntologyIRI(String ontologyIRI) { | ||
this.ontologyIRI = ontologyIRI; | ||
} | ||
public int getOwlClasses() { | ||
return owlClasses; | ||
} | ||
public void setOwlClasses(int owlClasses) { | ||
this.owlClasses = owlClasses; | ||
} | ||
public int getObjectProperties() { | ||
return objectProperties; | ||
} | ||
public void setObjectProperties(int objectProperties) { | ||
this.objectProperties = objectProperties; | ||
} | ||
public int getDatatypeProperties() { | ||
return datatypeProperties; | ||
} | ||
public void setDatatypeProperties(int datatypeProperties) { | ||
this.datatypeProperties = datatypeProperties; | ||
} | ||
public int getAnnotationProperties() { | ||
return annotationProperties; | ||
} | ||
public void setAnnotationProperties(int annotationProperties) { | ||
this.annotationProperties = annotationProperties; | ||
} | ||
public int getIndividuals() { | ||
return individuals; | ||
} | ||
public void setIndividuals(int individuals) { | ||
this.individuals = individuals; | ||
} | ||
public int getImportedOntologies() { | ||
return importedOntologies; | ||
} | ||
public void setImportedOntologies(int importedOntologies) { | ||
this.importedOntologies = importedOntologies; | ||
} | ||
|
||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/api/src/main/java/it/cnr/istc/stlab/ontonethub/UnmappableOntologyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package it.cnr.istc.stlab.ontonethub; | ||
|
||
/** | ||
* | ||
* @author Andrea Nuzzolese (https://github.com/anuzzolese) | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class UnmappableOntologyException extends Exception { | ||
|
||
private Exception e; | ||
private String ontologyID; | ||
|
||
public UnmappableOntologyException(String ontologyID, Exception e) { | ||
this.e = e; | ||
this.ontologyID = ontologyID; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return "The ontology with ID " + ontologyID + " cannot be mapped to any bundle."; | ||
} | ||
|
||
public Exception getE() { | ||
return e; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/api/src/main/java/it/cnr/istc/stlab/ontonethub/job/IndexingJobInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package it.cnr.istc.stlab.ontonethub.job; | ||
|
||
import com.hp.hpl.jena.rdf.model.Model; | ||
|
||
/** | ||
* The IndexingJobInput represents the input for an IndexingJob. | ||
* | ||
* @author Andrea Nuzzolese (https://github.com/anuzzolese) | ||
* | ||
*/ | ||
public class IndexingJobInput { | ||
|
||
private String name, description, baseURI, ontologyId; | ||
private Model data; | ||
|
||
public IndexingJobInput() { | ||
|
||
} | ||
|
||
public IndexingJobInput(String name, String description, String baseURI, Model data) { | ||
this.name = name; | ||
this.description = description; | ||
this.baseURI = baseURI; | ||
this.data = data; | ||
} | ||
|
||
public IndexingJobInput(String ontologyId, String name, String description, String baseURI, Model data) { | ||
this(name, description, baseURI, data); | ||
this.ontologyId = ontologyId; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getBaseURI() { | ||
return baseURI; | ||
} | ||
|
||
public void setBaseURI(String baseURI) { | ||
this.baseURI = baseURI; | ||
} | ||
|
||
public Model getData() { | ||
return data; | ||
} | ||
|
||
public void setData(Model data) { | ||
this.data = data; | ||
} | ||
|
||
public String getOntologyId() { | ||
return ontologyId; | ||
} | ||
|
||
public void setOntologyId(String ontologyId) { | ||
this.ontologyId = ontologyId; | ||
} | ||
|
||
} |