UMLS::Similarity::random - Perl module for computing a random baseline


UMLS-Similarity documentation Contained in the UMLS-Similarity distribution.

Index


Code Index:

NAME

Top

UMLS::Similarity::random - Perl module for computing a random baseline by assigning a random number between zero and one as the similarity score.

SYNOPSIS

Top

  use UMLS::Interface;
  use UMLS::Similarity::random;

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

  my $random = UMLS::Similarity::random->new($umls);
  die "Unable to create measure object.\n" if(!$random);

  my $cui1 = "C0005767";
  my $cui2 = "C0007634";

  $ts1 = $umls->getTermList($cui1);
  my $term1 = pop @{$ts1};

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

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

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

DESCRIPTION

Top

This module assigns a random number between zero and one as the semantic relatedness of two concepts in the UMLS

USAGE

Top

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

TYPICAL USAGE EXAMPLES

Top

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

   use UMLS::Similarity::random;
   $measure = UMLS::Similarity::random->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.

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');

SEE ALSO

Top

perl(1), UMLS::Interface

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

AUTHORS

Top

  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 AND LICENSE

Top


UMLS-Similarity documentation Contained in the UMLS-Similarity distribution.

# UMLS::Similarity::random.pm
#
# Module which assigns a random number between zero and one as 
# the similarity score
#
# Copyright (c) 2009-2011,
#
# Bridget T McInnes, University of Minnesota, Twin Cities
# bthomson at umn.edu
#
# Siddharth Patwardhan, University of Utah, Salt Lake City
# sidd at cs.utah.edu
#
# Serguei Pakhomov, University of Minnesota, Twin Cities
# pakh002 at umn.edu
#
# Ted Pedersen, University of Minnesota, Duluth
# tpederse at d.umn.edu
#
# Ying Liu, University of Minnesota
# liux0935 at umn.edu
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to 
#
# The Free Software Foundation, Inc., 
# 59 Temple Place - Suite 330, 
# Boston, MA  02111-1307, USA.


package UMLS::Similarity::random;

use strict;
use warnings;
use UMLS::Similarity;
use UMLS::Similarity::ErrorHandler;

use vars qw($VERSION);
$VERSION = '0.05';

my $debug = 0;

sub new
{
    my $className = shift;
    return undef if(ref $className);

    if($debug) { print STDERR "In UMLS::Similarity::random->new()\n"; }

    my $interface = shift;

    my $self = {};
     
    # Bless the object.
    bless($self, $className);
    
    # The backend interface object.
    $self->{'interface'} = $interface;
    
    return $self;
}


sub getRelatedness
{
    my $self = shift;

    return undef if(!defined $self || !ref $self);

    my $concept1 = shift;
    my $concept2 = shift;
    
    #  return a random number between zero and one
    my $score = rand();
    
    return $score
}

1;
__END__