WordNetResource extends AbstractResource { @Override public Set<Entity> getRelatedEntities(Entity entity, SemanticRelation semanticRelation) throws LexicalSemanticResourceException { Set<Entity> relatedEntities = new HashSet<Entity>(); Set<Synset> synsets = WordNetUtils.entityToSynsets(dict, entity, isCaseSensitive); for (Synset synset : synsets) { PointerTargetNodeList nodeList = getNodeListByRelation(synset, semanticRelation); if (nodeList != null) { for (Object node : nodeList) { PointerTargetNode ptNode = (PointerTargetNode) (node); Synset nodeSynset = ptNode.getSynset(); relatedEntities.add(WordNetUtils.synsetToEntity(nodeSynset)); } } } return relatedEntities; } WordNetResource();  WordNetResource(String wordNetPropertiesFile); @Override boolean containsLexeme(String lexeme); @Override boolean containsEntity(Entity entity); @Override Set<Entity> getEntity(String lexeme); @Override Set<Entity> getEntity(String lexeme, PoS pos); @Override Set<Entity> getEntity(String lexeme, PoS pos, String sense); Set<Entity> getEntity(String lexeme, PoS pos, int sense); @Override Set<Entity> getParents(Entity entity); @Override int getNumberOfEntities(); @Override Iterable<Entity> getEntities(); @Override Set<Entity> getChildren(Entity entity); @Override String getResourceName(); @Override String getResourceVersion(); @Override int getShortestPathLength(Entity firstEntity, Entity secondEntity); @Override String getGloss(Entity entity); @Override Set<String> getRelatedLexemes(String lexeme, PoS pos, String sense, LexicalRelation lexicalRelation); @Override Set<Entity> getRelatedEntities(Entity entity, SemanticRelation semanticRelation); Set<Entity> getRelatedEntitiesByName(Entity entity, String semanticRelation); @Override Entity getRoot(); @Override Entity getRoot(PoS pos); @Override Entity getMostFrequentEntity(String lexeme); @Override Entity getMostFrequentEntity(String lexeme, PoS pos); Dictionary getDict();  }
@Test public void testGetSemanticRelations() throws LexicalSemanticResourceException { wordnet.setIsCaseSensitive(false); Set<String> expectedHyponyms = new HashSet<String>(); expectedHyponyms.add("cladogram#13912424|---n"); expectedHyponyms.add("stemma#13912540|---n"); Set<Entity> hyponyms = wordnet.getRelatedEntities(new Entity("tree", PoS.n, "13912260"), SemanticRelation.hyponymy); for (Entity hyponym : hyponyms) { assertTrue(hyponym.toString(), expectedHyponyms.contains(hyponym.toString())); } Set<String> expectedCohyponyms = new HashSet<String>(); expectedHyponyms.add("cladogram#13912424|---n"); expectedHyponyms.add("stemma#13912540|---n"); Set<Entity> cohyponyms = wordnet.getRelatedEntities( new Entity("stemma", PoS.n, "13912540"), SemanticRelation.hyponymy); for (Entity cohyponym : cohyponyms) { assertTrue(cohyponym.toString(), expectedCohyponyms.contains(cohyponym.toString())); } wordnet.setIsCaseSensitive(true); expectedHyponyms = new HashSet<String>(); expectedHyponyms.add("cladogram#13912424|---n"); expectedHyponyms.add("stemma#13912540|---n"); hyponyms = wordnet.getRelatedEntities(new Entity("tree", PoS.n, "13912260"), SemanticRelation.hyponymy); for (Entity hyponym : hyponyms) { assertTrue(hyponym.toString(), expectedHyponyms.contains(hyponym.toString())); } hyponyms = wordnet.getRelatedEntities(new Entity("Tree", PoS.n, "13912260"), SemanticRelation.hyponymy); assertEquals(hyponyms.size(), 0); }