LeacockChodorowComparator extends PathBasedComparator { @Override public double getSimilarity(Entity e1, Entity e2) throws SimilarityException, LexicalSemanticResourceException { if (e1.equals(e2)) { return - Math.log(1.0 / (2*depth)); } double minPathLength = getShortestPathLength(e1, e2); if (minPathLength < 0.0) { return minPathLength; } double relatedness = - Math.log( (minPathLength+1) / (2*depth)); return relatedness; } LeacockChodorowComparator(LexicalSemanticResource lexSemResource); @Override double getSimilarity(Entity e1, Entity e2);  }
@Ignore("MySQL server with Wikipedia data not available") @Test public void testLC98WikipediaCategory() throws Exception { Assume.assumeTrue(Runtime.getRuntime().maxMemory() > 1000000000); LexicalSemanticResource wikiResource = ResourceFactory.getInstance() .get("wikipedia_category", "test"); LexSemResourceComparator comparator = new LeacockChodorowComparator(wikiResource); Set<Entity> entitiesAqua = wikiResource.getEntity("AQUA"); Set<Entity> entitiesSir = wikiResource.getEntity("SIR"); Set<Entity> entitiesUKP = wikiResource.getEntity("UKP"); assertTrue("AQUA", entitiesAqua.size() > 0); assertTrue("SIR", entitiesSir.size() > 0); assertTrue("UKP", entitiesUKP.size() > 0); assertEquals(2.0794, comparator.getSimilarity(entitiesAqua, entitiesAqua), epsilon); assertEquals(-Math.log(0.375), comparator.getSimilarity(entitiesAqua, entitiesSir), epsilon); }