Permalink
Browse files

[#72] provide a resolveIri method in the KB

  • Loading branch information...
1 parent 8b0a01a commit 6b5fc295b997685bff49a29aa7fc4cdf6eb740db @jnguyenx jnguyenx committed Mar 21, 2017
@@ -47,7 +47,7 @@ public ClassMatcher(BMKnowledgeBase kb) {
*/
public List<SimpleClassMatch> matchEntity(String entity, String tOnt) {
Set<String> tids = kb.getClassIdsByOntology(tOnt);
- return matchClassSets(Sets.newHashSet(entity), tids);
+ return matchClassSets(Sets.newHashSet(kb.resolveIri(entity)), tids);
}
public List<SimpleClassMatch> matchClassSets(Set<String> qids, Set<String> tids) {
@@ -351,9 +351,12 @@
public int getRootIndex();
-
-
-
+ /**
+ * Resolves a CURIE into an IRI, if possible.
+ *
+ * @return IRI version of a CURIE, or the string itself
+ */
+ public String resolveIri(String entity);
}
@@ -172,12 +172,8 @@ public void setKbMetdata(KBMetadata kbMetdata) {
}
private String getShortForm(IRI iri) {
- if (curieUtil.getCurieMap().isEmpty()) {
- return iri.toString();
- } else {
- String iriString = iri.toString();
- return curieUtil.getCurie(iriString).orElse(iriString);
- }
+ String iriString = iri.toString();
+ return curieUtil.getCurie(iriString).orElse(iriString);
}
private void populateLabelsFromOntology(LabelMapper labelMapper, OWLOntology ontology) {
@@ -1037,11 +1033,7 @@ protected String getIdentifier(OWLNamedObject obj) {
*/
private OWLClass getOWLClass(String id) {
Preconditions.checkNotNull(id);
- if (curieUtil.getCurieMap().isEmpty()) {
- return getOWLClass(IRI.create(id));
- } else {
- return getOWLClass(IRI.create(curieUtil.getIri(id).orElse(id)));
- }
+ return getOWLClass(IRI.create(curieUtil.getIri(id).orElse(id)));
}
/**
@@ -1067,12 +1059,7 @@ private OWLNamedIndividual getOWLNamedIndividual(IRI iri) {
*/
public OWLNamedIndividual getOWLNamedIndividual(String id) {
Preconditions.checkNotNull(id);
- //TODO: check - this is redundant code simply return getOWLNamedIndividual(IRI.create(curieUtil.getIri(id).orElse(id))); will suffice
- if (curieUtil.getCurieMap().isEmpty()) {
- return getOWLNamedIndividual(IRI.create(id));
- } else {
- return getOWLNamedIndividual(IRI.create(curieUtil.getIri(id).orElse(id)));
- }
+ return getOWLNamedIndividual(IRI.create(curieUtil.getIri(id).orElse(id)));
}
public Attribute getAttribute(String id) {
@@ -1144,4 +1131,9 @@ public EWAHCompressedBitmap getFilteredDirectTypesBM(Set<String> classIds, Strin
}
+ @Override
+ public String resolveIri(String entity) {
+ return curieUtil.getIri(entity).orElse(entity);
+ }
+
}
@@ -67,12 +67,8 @@
@ApiParam(value = "ontology to be matched, e.g. HP",
required = true) @PathParam("ontology") String ontology)
throws UnknownFilterException, IncoherentStateException {
-
- // TODO it's weird to resolve the curie here
- String resolveEntity = curieUtil.getIri(entity).orElse(entity);
-
List<SimpleClassMatch> matches =
- classMatcher.matchEntity(resolveEntity, ontology);
+ classMatcher.matchEntity(entity, ontology);
return matches;
}

0 comments on commit 6b5fc29

Please sign in to comment.