GermaNetResource extends AbstractResource { public Set<String> getRelatedLexemes(String lexeme, PoS pos, String sense, LexicalRelation lexicalRelation) throws LexicalSemanticResourceException { Set<String> resultLexemes = new HashSet<String>(); for (LexUnit lexUnit : gn.getLexUnits(lexeme, GermaNetUtils.mapPos(pos), true)) { if (Integer.toString(lexUnit.getSense()).equals(sense)) { if (lexicalRelation.equals(LexicalRelation.antonymy)) { for (LexUnit antonym : lexUnit.getRelatedLexUnits(LexRel.has_antonym)) { resultLexemes.add(antonym.getOrthForm()); } } else if (lexicalRelation.equals(LexicalRelation.synonymy)) { for (LexUnit synonym : lexUnit.getRelatedLexUnits(LexRel.has_synonym)) { resultLexemes.add(synonym.getOrthForm()); } } } } return resultLexemes; } GermaNetResource(String path, boolean ignoreCase);  GermaNetResource(String path); 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> getChildren(Entity entity); Iterable<Entity> getEntities(); int getNumberOfEntities(); Set<Entity> getParents(Entity entity); String getResourceName(); String getResourceVersion(); int getShortestPathLength(Entity firstEntity, Entity secondEntity); String getGloss(Entity entity); Set<String> getRelatedLexemes(String lexeme, PoS pos, String sense, LexicalRelation lexicalRelation); Set<Entity> getRelatedEntities(Entity entity, SemanticRelation semanticRelation); @Override Entity getRoot(); @Override Entity getRoot(PoS pos); @Override Entity getMostFrequentEntity(String lexeme); @Override Entity getMostFrequentEntity(String lexeme, PoS pos);  }
@Test public void testGetLexicalRelations() throws LexicalSemanticResourceException { Set<String> expectedAntonyms = new HashSet<String>(); expectedAntonyms.add("warm"); Set<String> expectedSynonyms = new HashSet<String>(); expectedSynonyms.add("hartherzig"); expectedSynonyms.add("hart"); expectedSynonyms.add("kaltherzig"); Set<String> antonyms = germaNetCaseInsensitive.getRelatedLexemes("kalt", PoS.adj, "3", LexicalRelation.antonymy); assertEquals(1, antonyms.size()); for (String antonym : antonyms) { assertTrue(antonym, expectedAntonyms.contains(antonym)); } antonyms = germaNet.getRelatedLexemes("kAlt", PoS.adj, "3", LexicalRelation.antonymy); assertEquals(0, antonyms.size()); Set<String> synonyms = germaNetCaseInsensitive.getRelatedLexemes("kalt", PoS.adj, "1", LexicalRelation.synonymy); assertEquals(3, synonyms.size()); for (String synonym : synonyms) { assertTrue(synonym, expectedSynonyms.contains(synonym)); } synonyms = germaNet.getRelatedLexemes("kAlt", PoS.adj, "1", LexicalRelation.synonymy); assertEquals(0, synonyms.size()); }