WikipediaArticleResource extends AbstractResource { public Set<String> getRelatedLexemes(String lexeme, PoS pos, String sense, LexicalRelation lexicalRelation) throws LexicalSemanticResourceException { Entity entity = WikipediaArticleUtils.lexemeToEntity(wiki, lexeme, isCaseSensitive); Set<String> relatedLexemes = new HashSet<String>(); if (entity == null) { return relatedLexemes; } if (lexicalRelation.equals(LexicalRelation.antonymy)) { logger.warn("Wikipedia contains no antonymy information. Returning empty set."); } else if (lexicalRelation.equals(LexicalRelation.synonymy)) { for (String synonym : entity.getLexemes()) { String plainSynonym = WikipediaArticleUtils.plainString(synonym); if (!plainSynonym.equals(lexeme)) { relatedLexemes.add(plainSynonym); } } } return relatedLexemes; } WikipediaArticleResource(String host, String database, String user, String password, Language language);  WikipediaArticleResource(DatabaseConfiguration dbConfig);  WikipediaArticleResource(Wikipedia wiki); 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(); Set<String> getRelatedLexemes(String lexeme, PoS pos, String sense, LexicalRelation lexicalRelation); int getShortestPathLength(Entity e1, Entity e2); String getGloss(Entity entity); 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 testGetRelatedLexemes() throws LexicalSemanticResourceException { wikiResource.setIsCaseSensitive(false); Set<String> expectedSynonyms = new HashSet<String>(); expectedSynonyms.add("SIR"); Set<String> synonyms = wikiResource.getRelatedLexemes( "Semantic Information Retrieval", PoS.unk, Entity.UNKNOWN_SENSE, LexicalRelation.synonymy); assertEquals(expectedSynonyms.size(), synonyms.size()); for (String synonym : synonyms) { assertTrue(synonym, expectedSynonyms.contains(synonym)); } assertEquals( 0, wikiResource.getRelatedLexemes("Iryna Gurevych", PoS.unk, Entity.UNKNOWN_SENSE, LexicalRelation.synonymy).size()); wikiResource.setIsCaseSensitive(true); expectedSynonyms = new HashSet<String>(); expectedSynonyms.add("SIR"); synonyms = wikiResource.getRelatedLexemes( "Semantic Information Retrieval", PoS.unk, Entity.UNKNOWN_SENSE, LexicalRelation.synonymy); assertEquals(expectedSynonyms.size(), synonyms.size()); for (String synonym : synonyms) { assertTrue(synonym, expectedSynonyms.contains(synonym)); } assertEquals( 0, wikiResource.getRelatedLexemes("Iryna Gurevych", PoS.unk, Entity.UNKNOWN_SENSE, LexicalRelation.synonymy).size()); synonyms = wikiResource.getRelatedLexemes( "semantic Information Retrieval", PoS.unk, Entity.UNKNOWN_SENSE, LexicalRelation.synonymy); assertEquals(0, synonyms.size()); }