++ed by:
1 non-PAUSE user
Author image Bridget McInnes


UMLS::Similarity::nam - Perl module for computing semantic relatedness of concepts in the Unified Medical Language System (UMLS) using the method described by Nguyen and Al-Mubaid (2006)


  use UMLS::Interface;
  use UMLS::Similarity::nam;

  my $umls = UMLS::Interface->new(); 
  die "Unable to create UMLS::Interface object.\n" if(!$umls);
  ($errCode, $errString) = $umls->getError();
  die "$errString\n" if($errCode);

  my $nam = UMLS::Similarity::nam->new($umls);
  die "Unable to create measure object.\n" if(!$nam);
  my $cui1 = "C0005767";
  my $cui2 = "C0007634";
  @ts1 = $umls->getTermList($cui1);
  my $term1 = pop @ts1;

  @ts2 = $umls->getTermList($cui2);
  my $term2 = pop @ts2;

  my $value = $nam->getRelatedness($cui1, $cui2);

  print "The similarity between $cui1 ($term1) and $cui2 ($term2) is $value\n";


The Nguyen and Al-Mubaid measure calculates similarity by calculating the log of two plus the product of the shortest distance between the two concepts minus one and the depth of the taxonomy minus the depth of the LCS. Concepts that are more similar with have a lower similarity score than concepts that are less similar with this measure.


The semantic relatedness modules in this distribution are built as classes that expose the following methods: new() getRelatedness() getError() getTraceString()

See the UMLS::Similarity(3) documentation for details of these methods.


To create an object of the nam measure, we would have the following lines of code in the perl program.

   use UMLS::Similarity::nam;
   $measure = UMLS::Similarity::nam->new($interface);

The reference of the initialized object is stored in the scalar variable '$measure'. '$interface' contains an interface object that should have been created earlier in the program (UMLS-Interface).

If the 'new' method is unable to create the object, '$measure' would be undefined. This, as well as any other error/warning may be tested.

   die "Unable to create object.\n" if(!defined $measure);
   ($err, $errString) = $measure->getError();
   die $errString."\n" if($err);

To find the semantic relatedness of the concept 'blood' (C0005767) and the concept 'cell' (C0007634) using the measure, we would write the following piece of code:

   $relatedness = $measure->getRelatedness('C0005767', 'C0007634');

To get traces for the above computation:

   print $measure->getTraceString();

However, traces must be enabled using configuration files. By default traces are turned off.


perl(1), UMLS::Interface

perl(1), UMLS::Similarity(3)


  If you have any trouble installing and using UMLS-Similarity, 
  please contact us via the users mailing list :
  You can join this group by going to:
  You may also contact us directly if you prefer :
      Bridget T. McInnes: bthomson at cs.umn.edu 

      Ted Pedersen : tpederse at d.umn.edu


  Bridget T McInnes <bthomson at cs.umn.edu>
  Siddharth Patwardhan <sidd at cs.utah.edu>
  Serguei Pakhomov <pakh0002 at umn.edu>
  Ted Pedersen <tpederse at d.umn.edu>


Copyright 2004-2009 by Bridget T McInnes, Siddharth Patwardhan, Serguei Pakhomov and Ted Pedersen

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.