WordNetResource extends AbstractResource { @Override public boolean containsEntity(Entity entity) throws LexicalSemanticResourceException { Set<Synset> synsets = WordNetUtils.entityToSynsets(dict, entity, isCaseSensitive); if (synsets.size() == 0) { return false; } return true; } 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 testContainsEntity() throws Exception { wordnet.setIsCaseSensitive(false); assertTrue(wordnet.containsEntity(new Entity("tree"))); assertTrue(wordnet.containsEntity(new Entity("Tree"))); assertTrue(wordnet.containsEntity(new Entity("tree", PoS.n))); assertTrue(wordnet.containsEntity(new Entity("Tree", PoS.n))); assertTrue(wordnet.containsEntity(new Entity("tree", PoS.v))); assertTrue(wordnet.containsEntity(new Entity("Tree", PoS.v))); assertTrue(wordnet.containsEntity(new Entity("knocked-out", PoS.adj, "680634"))); assertTrue(wordnet.containsEntity(new Entity("KnoCked-ouT", PoS.adj, "680634"))); assertFalse(wordnet.containsEntity(new Entity("tree", PoS.adj))); assertFalse(wordnet.containsEntity(new Entity("humbelpfh"))); wordnet.setIsCaseSensitive(true); assertTrue(wordnet.containsEntity(new Entity("tree"))); assertFalse(wordnet.containsEntity(new Entity("TrEe"))); assertTrue(wordnet.containsEntity(new Entity("tree", PoS.n))); assertFalse(wordnet.containsEntity(new Entity("Tree", PoS.n))); assertTrue(wordnet.containsEntity(new Entity("tree", PoS.v))); assertFalse(wordnet.containsEntity(new Entity("Rree", PoS.v))); assertTrue(wordnet.containsEntity(new Entity("knocked-out", PoS.adj, "680634"))); assertFalse(wordnet.containsEntity(new Entity("Knocked-out", PoS.adj, "680634"))); assertFalse(wordnet.containsEntity(new Entity("tree", PoS.adj))); assertFalse(wordnet.containsEntity(new Entity("Tree", PoS.adj))); assertFalse(wordnet.containsEntity(new Entity("humbelpfh"))); }
@Test public void testContainsEntitySpecialCases() throws Exception { Map<String, String> automotiveVehicleLexemes = new HashMap<String, String>(); automotiveVehicleLexemes.put("automotive_vehicle", "3791235"); automotiveVehicleLexemes.put("motor_vehicle", "3791235"); Entity automotiveVehicleEntity = new Entity(automotiveVehicleLexemes, PoS.n); wordnet.setIsCaseSensitive(false); assertTrue(automotiveVehicleEntity.toString(), wordnet .containsEntity(automotiveVehicleEntity)); wordnet.setIsCaseSensitive(true); assertTrue(automotiveVehicleEntity.toString(), wordnet .containsEntity(automotiveVehicleEntity)); }