Skip to content

Commit

Permalink
fix: handling empty dbpedia class
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob committed Apr 27, 2020
1 parent 416c618 commit c976dd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/java/edu/isi/oba/ObaUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ private static JSONObject run_owl_jsonld(String ontology_url) throws Exception {
}
if (result != null){
JSONObject json = new JSONObject(result.toString());
//TODO: This is a hack to remove
// "": {"@id": "http://dbpedia.org/ontology/"}
//temp_json is a reference to json
JSONObject temp_json = (JSONObject) json.get("@context");

if (!temp_json.isNull("")) {
logger.warning("Generating of context.json - Ignoring the class " + temp_json.get("") + ": Name is empty.");
temp_json.remove("");
}
return json;
}
while ((s = stdError.readLine()) != null) {
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/edu/isi/oba/SerializerPython.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.*;

import static edu.isi.oba.Oba.SERVERS_DIRECTORY;
import static edu.isi.oba.Oba.logger;

class SerializerPython {
static final String name = "python";
Expand Down Expand Up @@ -71,8 +72,15 @@ private void add_variable_python(FileWriter myWriter, Iterator it) {
name = (String) pair.getValue();
try {
String variable_name = name.toUpperCase().replace("-", "");
myWriter.write(variable_name + "_TYPE_URI = \"" + clsIRI + "\"\n");
myWriter.write(variable_name + "_TYPE_NAME = \"" + name + "\"\n");
//TODO: Catch class name empty
String catch_temp = name.replace("<", "").replace(">", "");
if (!catch_temp.equals(clsIRI.toString())) {
myWriter.write(variable_name + "_TYPE_URI = \"" + clsIRI + "\"\n");
myWriter.write(variable_name + "_TYPE_NAME = \"" + name + "\"\n");
}
else {
logger.warning("Ignoring class " + clsIRI);
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
Expand Down

0 comments on commit c976dd3

Please sign in to comment.