question: @ Override protected List < Double > computeRelatedness ( Page page1 , Page page2 ) throws WikiApiException { List < Double > relatednessValues = new ArrayList < Double > ( ) ; Set < Category > categories1 = relatednessUtilities . getCategories ( page1 ) ; Set < Category > categories2 = relatednessUtilities . getCategories ( page2 ) ; if ( categories1 == null || categories2 == null ) { return null ; } double depthOfHierarchy = catGraph . getDepth ( ) ; if ( depthOfHierarchy == 0 ) { logger . info ( "The depth of the hierarchy is 0. Cannot compute LeacockChodorow relatedness." ) ; return null ; } for ( Category cat1 : categories1 ) { for ( Category cat2 : categories2 ) { int pathLength = catGraph . getTaxonomicallyBoundPathLengthInEdges ( cat1 , cat2 ) ; if ( pathLength < 0 ) { continue ; } double relatedness = Math . log ( ( 2 * depthOfHierarchy ) / ( pathLength + 1 ) ) ; relatednessValues . add ( relatedness ) ; } } return relatednessValues ; }
target:  Implements the distance measure by Leacock and Chodorow (1998) lch(c1,c2) = - log(minPathLength(c1,c2) / 2 * depth of the hierarchy) lch(c1,c2) = - log(minPL(c1,c2) / 2 * depth) = log ( 2*depth / minPL(c1,c2) ) minPathLength is measured in nodes, i.e. the distance of a node to itself is 0! This would cause a logarithm error (or a division by zero)). Thus we changed the behaviour in order to return a distance of 1, if the nodes are equal or neighbors.