GermaNetResource extends AbstractResource { public Iterable<Entity> getEntities() throws LexicalSemanticResourceException { return new GermaNetEntityIterable(gn); } 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 testGetEntities() throws LexicalSemanticResourceException { for (Entity entity : germaNetCaseInsensitive.getEntities()) { assertTrue(entity.toString(), germaNetCaseInsensitive.containsEntity(entity)); } for (Entity entity : germaNet.getEntities()) { assertTrue(entity.toString(), germaNet.containsEntity(entity)); } }
@Test public void testAmbiguity() throws LexicalSemanticResourceException { Map<String,Integer> lexemeMap = new HashMap<String,Integer>(); for (Entity entity : germaNetCaseInsensitive.getEntities()) { for (String lexeme : entity.getLexemes()) { int count = 1; if (lexemeMap.containsKey(lexeme)) { count = lexemeMap.get(lexeme) + 1; } lexemeMap.put(lexeme, count); } } int sum = 0; int polysemCount = 0; for (int count : lexemeMap.values()) { sum += count; if (count > 1) { polysemCount++; } } System.out.println("Polysemy fraction: " + (double) polysemCount / lexemeMap.size()); System.out.println("Average polysemy: " + (double) sum / lexemeMap.size()); }