Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ public LocalOntology() {
//only initialize all the static variables
//if first time called to this ontology constructor
if (ontology == null) {
if (LOG.isInfoEnabled()) {
LOG.info("Creating new ontology");
}
parser = new OwlParser();
LOG.info("Creating new ontology client and parser implementation.");
parser = new OntologyParserImpl();
ontology = this;
}
if (ontologyModel == null)
Expand All @@ -87,24 +85,25 @@ public Ontology getInstance() {
}

/**
* Load the default <i>sweetAll.owl</i> ontology
* from <a href="https://raw.githubusercontent.com/ESIPFed/sweet/master/2.4/sweetAll.owl">
* https://raw.githubusercontent.com/ESIPFed/sweet/master/2.4/sweetAll.owl</a>
* Load the default <i>sweetAll.ttl</i> ontology
* from <a href="http://sweetontology.net/sweetAll.ttl">
* http://sweetontology.net/sweetAll.ttl</a>
*/
@Override
public void load() {
URL ontURL = null;
try {
ontURL = new URL("https://raw.githubusercontent.com/ESIPFed/sweet/master/2.4/sweetAll.owl");
//ontURL = new URL("https://raw.githubusercontent.com/ESIPFed/sweet/master/2.4/reprDataProduct.owl");
ontURL = new URL("http://sweetontology.net/sweetAll.ttl");
} catch (MalformedURLException e) {
LOG.error("Error when attempting to create URL resource: ", e);
}
ontArrayList = new ArrayList<>();
try {
ontArrayList.add(ontURL.toURI().toString());
} catch (URISyntaxException e) {
LOG.error("Error in URL syntax, please check your Ontology resource: ", e);
if (ontURL != null) {
try {
ontArrayList.add(ontURL.toURI().toString());
} catch (URISyntaxException e) {
LOG.error("Error in URL syntax, please check your Ontology resource: ", e);
}
}
if (!ontArrayList.isEmpty()) {
load(ontArrayList.stream().toArray(String[]::new));
Expand All @@ -126,8 +125,21 @@ public void load(String[] urls) {
}

private void load(Object m, String url) {
String lang = null;
try {
((OntModel) m).read(url, null, null);
switch (url.substring(url.lastIndexOf('.') + 1)) {
case "ttl":
lang = "TURTLE";
break;
//null represents the default language, "RDF/XML".
//"RDF/XML-ABBREV" is a synonym for "RDF/XML".
case "rdf":
case "owl": {
lang = "RDF/XML";
break;
}
}
((OntModel) m).read(url, null, lang);
LOG.info("Successfully processed {}", url);
} catch (Exception e) {
LOG.error("Failed whilst attempting to read ontology {}: Error: ", url, e);
Expand All @@ -141,7 +153,7 @@ private void load(Object m, String url) {
*/
public OntologyParser getParser() {
if (parser == null) {
parser = new OwlParser();
parser = new OntologyParserImpl();
}
return parser;
}
Expand Down Expand Up @@ -229,6 +241,7 @@ public Iterator<String> subclasses(String entitySearchTerm) {
* @return an {@link java.util.Iterator} containing synonyms string tokens
* or an empty if no synonyms exist for the given queryKeyPhrase.
*/
@SuppressWarnings("unchecked")
@Override
public Iterator synonyms(String queryKeyPhrase) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
* implementation for <a href="http://www.w3.org/TR/owl-features/">W3C OWL</a>
* files.
*/
public class OwlParser implements OntologyParser {
public class OntologyParserImpl implements OntologyParser {

private Ontology ont;
private List<OntClass> roots = new ArrayList<>();

public OwlParser() {
public OntologyParserImpl() {
//default constructor
}

Expand Down Expand Up @@ -122,7 +122,7 @@ public Iterator<OntClass> rootClasses(OntModel m) {
//assume ontology has root classes
processSingle(m);
} else {
//check for presence of aggregate/collection ontologies such as sweetAll.owl
//check for presence of aggregate/collection ontologies such as sweetAll.ttl
processCollection(m);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;

public class NormalizeFeatures extends DiscoveryStepAbstract {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
*/
package org.apache.sdap.mudrod.ontology.process;

import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.IOException;

Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<findbugs.version>3.0.4</findbugs.version>
<xml.maven.version>1.0.1</xml.maven.version>
<jacoco.version>0.8.0</jacoco.version>
<jena.version>3.3.0</jena.version>
<jena.version>3.6.0</jena.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<elastic.version>5.2.0</elastic.version>
</properties>
Expand Down Expand Up @@ -494,6 +494,12 @@
<version>${jena.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>${jena.version}</version>
</dependency>
<!-- End of Jena dependencies -->
<!-- Misc dependencies -->
<dependency>
Expand Down