# UMLS::Similarity::lch.pm # # Module implementing the semantic relatedness measure described # by Leacock and Chodorow (1998). # sub getRelatedness { my $self = shift; return undef if(!defined $self || !ref $self); my $concept1 = shift; my $concept2 = shift; # get the interfaceg my $interface = $self->{'interface'}; # find the length of the shortest path # if concept 1 and 2 are the same just return 1 my $length = 0; if($concept1 eq $concept2) { $length = 1; } else { $length = $interface->findShortestPathLength($concept1, $concept2); } # get the depth of the taxonomy my $depth = $interface->depth(); # if the length of hte path is less than zero return -1 if($length < 0) { return -1; } # calculate lch my $score = -1 * log ($length / (2 * $depth)); return $score; } =