WikipediaArticleResource extends AbstractResource { public Set<Entity> getEntity(String lexeme) throws LexicalSemanticResourceException { Set<Entity> entitySet = new HashSet<Entity>(); if (!containsLexeme(lexeme)) { return entitySet; } Entity e = WikipediaArticleUtils.lexemeToEntity(wiki, lexeme, isCaseSensitive); if (e != null) { entitySet.add(e); } return entitySet; } 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 testGetEntity() throws LexicalSemanticResourceException { Set<String> expectedResults = new HashSet<String>(); expectedResults.add(getSirEntity().getId()); Set<Entity> entities; wikiResource.setIsCaseSensitive(false); entities = wikiResource.getEntity("SIR"); assertEquals(expectedResults.size(), entities.size()); for (Entity entity : entities) { assertTrue(entity.toString(), expectedResults.contains(entity.toString())); } wikiResource.setIsCaseSensitive(true); entities = wikiResource.getEntity("SIR"); assertEquals(expectedResults.size(), entities.size()); for (Entity entity : entities) { assertTrue(entity.toString(), expectedResults.contains(entity.toString())); } entities = wikiResource.getEntity("siR"); assertEquals(0, entities.size()); }
@Test public void testGetEntityPos() throws LexicalSemanticResourceException { Set<String> expectedResults = new HashSet<String>(); expectedResults.add(getSirEntity().getId()); Set<Entity> entities; wikiResource.setIsCaseSensitive(false); entities = wikiResource.getEntity("SIR", PoS.unk); assertEquals(expectedResults.size(), entities.size()); for (Entity entity : entities) { assertTrue(entity.toString(), expectedResults.contains(entity.toString())); } wikiResource.setIsCaseSensitive(true); entities = wikiResource.getEntity("SIR", PoS.unk); assertEquals(expectedResults.size(), entities.size()); for (Entity entity : entities) { assertTrue(entity.toString(), expectedResults.contains(entity.toString())); } entities = wikiResource.getEntity("sIR", PoS.unk); assertEquals(0, entities.size()); }
@Test public void testGetEntityPos2() throws LexicalSemanticResourceException { Set<String> expectedResults = new HashSet<String>(); expectedResults.add(getSirEntity().getId()); Set<Entity> entities; entities = wikiResource.getEntity("SIR", PoS.adj); assertEquals(expectedResults.size(), entities.size()); }