LocalOntology implements Ontology { @Override public Iterator synonyms(String queryKeyPhrase) { Map<?, ?> classMap = retrieve(queryKeyPhrase); Map<Object, Object> synonyms = new HashMap<>(); Iterator<?> iter = classMap.keySet().iterator(); while (iter.hasNext()) { OntResource resource = (OntResource) iter.next(); for (Iterator<?> i = resource.listLabels(null); i.hasNext();) { Literal l = (Literal) i.next(); synonyms.put(l.toString(), "1"); } if (resource instanceof Individual) { for (Iterator<?> i = resource.listSameAs(); i.hasNext();) { Individual individual = (Individual) i.next(); for (Iterator<?> j = individual.listLabels(null); j.hasNext();) { Literal l = (Literal) i.next(); synonyms.put(l.toString(), "1"); } } } else if (resource instanceof OntClass) { for (Iterator<?> i = ((OntClass) resource).listEquivalentClasses(); i.hasNext();) { OntClass equivClass = (OntClass) i.next(); for (Iterator<?> j = equivClass.listLabels(null); j.hasNext();) { Literal l = (Literal) j.next(); synonyms.put(l.toString(), "1"); } } } } return synonyms.keySet().iterator(); } LocalOntology(); Ontology getInstance(); @Override void load(); @Override void load(String[] urls); OntologyParser getParser(); static OntModel getModel(); List<String> getLoadedOntologyResources(); @Override void merge(Ontology o); @Override Iterator<String> subclasses(String entitySearchTerm); @Override Iterator synonyms(String queryKeyPhrase); void addSearchTerm(String label, OntResource resource); Map<OntResource, String> retrieve(String label); static void renderClassDescription(PrintStream out, OntClass c, int depth); static final Logger LOG; static final String DELIMITER_SEARCHTERM; }
@Ignore @Test public final void testSynonyms() { fail("Not yet implemented"); }