WikipediaCategoryResource extends AbstractResource { public Set<Entity> getParents(Entity entity) throws LexicalSemanticResourceException { Set<Entity> parents = new HashSet<Entity>(); Category cat; String lexeme = WikipediaCategoryUtils.getCaseSensitiveLexeme(entity.getFirstLexeme(), isCaseSensitive); if (lexeme == null) { return parents; } try { cat = wiki.getCategory(lexeme); if (cat == null) { return parents; } Set<Category> parentCategories = cat.getParents(); for (Category parentCategory : parentCategories) { parents.add(new Entity(parentCategory.getTitle().getWikiStyleTitle())); } } catch (WikiApiException e) { throw new LexicalSemanticResourceException(e); } return parents; } WikipediaCategoryResource(DatabaseConfiguration dbConfig);  WikipediaCategoryResource(Wikipedia wiki);  WikipediaCategoryResource(String host, String database, String user, String password, Language language); boolean containsEntity(Entity entity); boolean containsLexeme(String lexeme); Set<Entity> getEntity(String lexeme); Set<Entity> getEntity(String lexeme, PoS pos); Set<Entity> getEntity(String lexeme, PoS pos, String sense); Set<Entity> getParents(Entity entity); int getNumberOfEntities(); Iterable<Entity> getEntities(); Set<Entity> getChildren(Entity entity); String getResourceName(); String getResourceVersion(); int getShortestPathLength(Entity firstEntity, Entity secondEntity); @Override Entity getRoot(); @Override Entity getRoot(PoS pos); String getGloss(Entity entity); Set<String> getRelatedLexemes(String lexeme, PoS pos, String sense, LexicalRelation lexicalRelation); Set<Entity> getRelatedEntities(Entity entity, SemanticRelation semanticRelation); @Override Entity getMostFrequentEntity(String lexeme); @Override Entity getMostFrequentEntity(String lexeme, PoS pos);  }
@Test public void testGetParents() throws Exception { wikiResource.setIsCaseSensitive(false); Set<Entity> parents = wikiResource.getParents(new Entity( "Publications_of_Telecooperation")); Set<String> expectedParents = new HashSet<String>(); expectedParents.add("Telecooperation#-|---unk"); assertEquals(expectedParents.size(), parents.size()); for (Entity parent : parents) { assertTrue(parent.toString(), expectedParents.contains(parent.toString())); } assertEquals(0, wikiResource.getParents(new Entity("Telecooperation")) .size()); wikiResource.setIsCaseSensitive(true); parents = wikiResource.getParents(new Entity( "Publications_of_Telecooperation")); expectedParents = new HashSet<String>(); expectedParents.add("Telecooperation#-|---unk"); assertEquals(expectedParents.size(), parents.size()); for (Entity parent : parents) { assertTrue(parent.toString(), expectedParents.contains(parent.toString())); } assertEquals(0, wikiResource.getParents(new Entity("Telecooperation")) .size()); parents = wikiResource.getParents(new Entity( "publications_of_Telecooperation")); assertEquals(parents.size(), 0); }