LinComparator extends PathBasedComparator { @Override public double getSimilarity(Entity e1, Entity e2) throws SimilarityException, LexicalSemanticResourceException { if (e1.equals(e2)) { return 1.0; } double relatedness = NOT_FOUND; try { Entity lcs = getEntityGraph().getLCS(this.root, e1, e2); if (lcs == null) { return NO_LCS; } double iicLcs = getEntityGraph().getIntrinsicInformationContent(lcs); double iicE1 = getEntityGraph().getIntrinsicInformationContent(e1); double iicE2 = getEntityGraph().getIntrinsicInformationContent(e2); if (iicE1 == 0 && iicE2 == 0) { return 0.0; } relatedness = 2*iicLcs / (iicE1 + iicE2); } catch (UnsupportedOperationException e) { throw new LexicalSemanticResourceException(e); } return relatedness; } LinComparator(LexicalSemanticResource lexSemResource);  LinComparator(LexicalSemanticResource lexSemResource, Entity root); @Override double getSimilarity(Entity e1, Entity e2);  }
@Test @Ignore("See bug 164") public void testLinGermaNet() throws Exception { LexicalSemanticResource germaNet = ResourceFactory.getInstance().get("germanet", "de"); LexSemResourceComparator comparator = new LinComparator(germaNet, germaNet.getRoot()); assertEquals("LinComparator", comparator.getName()); Set<Entity> entities1 = germaNet.getEntity("Quelle"); Set<Entity> entities2 = germaNet.getEntity("Text"); Set<Entity> entities3 = germaNet.getEntity("Kommunikation"); Set<Entity> entities4 = germaNet.getEntity("überzeugen"); Set<Entity> entities5 = germaNet.getEntity("Macht"); Set<Entity> entities6 = germaNet.getEntity("Reich"); assertEquals(LinComparator.NOT_FOUND, comparator.getSimilarity(entities1, entities2), epsilon); assertEquals(LinComparator.NOT_FOUND, comparator.getSimilarity(entities3, entities4), epsilon); assertEquals(0.0, comparator.getSimilarity(entities5, entities6), epsilon); }