Superman has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (strings)
I have 2 strings which should be identical:
and I test for this normally:$PDBline; $XMLline;
However in the event that they dont match I want to do a percentage comparison where I match each word in $PDBline against the words in $XMLline.if ($PDBline eq $XMLline){etc...}
So say I want a 75 % similarity between the 2 strings...
Does this seem right or is there an easier way to do this??my $threshold = 0.75; my $counter = 0; foreach my $word ( split ' ', $PDBline ) { $counter++ if $XMLline =~ /$word/; }
Originally posted as a Categorized Question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I find the percentage of similarity between strings?⭐
by I0 (Priest) on Apr 25, 2002 at 20:43 UTC | |
Re: How do I find the percentage of similarity between strings?⭐
by The Mad Hatter (Priest) on Apr 07, 2003 at 22:31 UTC | |
Re: How do I find the percentage of similarity between strings?
by chicks (Scribe) on Apr 26, 2002 at 01:50 UTC | |
Re: How do I find the percentage of similarity between strings?
by Superman (Acolyte) on Apr 26, 2002 at 08:26 UTC | |
Re: How do I find the percentage of similarity between strings?
by Anonymous Monk on Apr 07, 2003 at 22:08 UTC |
Back to
Seekers of Perl Wisdom