in reply to Re: Use of uninitialized value $cui1 in print
in thread Use of uninitialized value $cui1 in print

Error1 is: ...

Ok, so what's the code that produces the error? I don't see any  eq operator ("string eq") in the OPed code, nor a  $concept1 scalar. (Update: A small point: a "warning" (see warnings, which you are wise to use, as you seem to be doing) is not an error, but merits your attention nonetheless.)

Update: Rats. Many small changes to added update sentence in preceding paragraph just to get it to make sense!


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: Use of uninitialized value $cui1 in print
by Raksha Jalan (Initiate) on Mar 03, 2017 at 03:44 UTC
    # UMLS::Similarity::lch.pm # # Module implementing the semantic relatedness measure described # by Leacock and Chodorow (1998). # <code> 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, $co +ncept2); } # 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; } =

    this subroutine in code is by default present in umls::similarity package. Where our $t1 is passes as $concept1 and $t2 is passed as $concept 2.So I dont think there is anything wrong in this code.What am I thinking is maybe $t1 is not able to get value as string the way it should be.Well I am beginner so I dont have much knowledge so plz help me

      I have never used nor even seen the UMLS::Similarity::lch module before and, after a brief perusal, have only the vaguest idea of what it is supposed to do. However, total ignorance should never prevent a righteous monk from offering an opinion! So...

      my $cu1 = $umls->getConceptList($t1); #calling function from umls::sim +ilarity #ERRRO 1 as mentioned my $cui1 =pop @{$cu1}; my $cu2 = $umls->getConceptList($t2);***error my $cui2 = pop @{$cu2}; print $cui1; # ****ERROR2 unintialized $cui1 my $lvalue = $lch->getRelatedness($cui1, $cui2);

      If the value (which should be an array reference) returned to  $cu1 by the call to the  getConceptList() method in the
          my $cu1 = $umls->getConceptList($t1); #calling function from umls::similarity #ERRRO 1 as mentioned
      statement is undefined or is a reference to an empty array, the value assigned to  $cui1 by the pop in
           my $cui1 =pop @{$cu1};
      will be undefined, as your comment to the
           print $cui1;    # ****ERROR2 unintialized $cui1
      statement suggests.

      Because an undefined  $cui1 will become an undefined  $concept1 within the call to the  getRelatedness() method, you will get a warning like "Use of uninitialized value $concept1 in string eq at UMLS/Similarity/lch.pm ... at the line number associated with the
          if($concept1 eq $concept2) { $length = 1; }
      statement in getRelatedness().

      So your first step is to determine whether  $cu1 is undefined or a reference to an empty array. I would do this with a Data::Dumper print debugging statement after the method call:
          my $cu1 = $umls->getConceptList($t1);
          print Dumper $cu1;
      Once you know the value of $cu1, you can figure out from the documentation (or the source) of  getConceptList() why it has this value given that you know the value $t1.

      I hope this helps. It seems you've already gone quite a way through the steps I've outlined, but maybe this will help clarify things a bit.


      Give a man a fish:  <%-{-{-{-<