Similarity(3pm) User Contributed Perl Documentation Similarity(3pm)NAME
String::Similarity - calculate the similarity of two strings
SYNOPSIS
use String::Similarity;
$similarity = similarity $string1, $string2;
$similarity = similarity $string1, $string2, $limit;
DESCRIPTION
$factor = similarity $string1, $string2, [$limit]
The "similarity"-function calculates the similarity index of its two arguments. A value of 0 means that the strings are entirely
different. A value of 1 means that the strings are identical. Everything else lies between 0 and 1 and describes the amount of
similarity between the strings.
It roughly works by looking at the smallest number of edits to change one string into the other.
You can add an optional argument $limit (default 0) that gives the minimum similarity the two strings must satisfy. "similarity" stops
analyzing the string as soon as the result drops below the given limit, in which case the result will be invalid but lower than the
given $limit. You can use this to speed up the common case of searching for the most similar string from a set by specifying the
maximum similarity found so far.
SEE ALSO
The basic algorithm is described in:
"An O(ND) Difference Algorithm and its Variations", Eugene Myers,
Algorithmica Vol. 1 No. 2, 1986, pp. 251-266;
see especially section 4.2, which describes the variation used below.
The basic algorithm was independently discovered as described in:
"Algorithms for Approximate String Matching", E. Ukkonen,
Information and Control Vol. 64, 1985, pp. 100-118.
AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/
(the underlying fstrcmp function was taken from gnu diffutils and
modified by Peter Miller <pmiller@agso.gov.au> and Marc Lehmann
<schmorp@schmorp.de>).
perl v5.14.2 2012-03-15 Similarity(3pm)
Check Out this Related Man Page
fstrcasecmpi(3) Library Functions Manual fstrcasecmpi(3)NAME
fstrcasecmpi - fuzzy comparison of two strings ignoring case
SYNOPSIS
#include <fstrcmp.h>
#define FSTRCMP_IDENTICAL
#define FSTRCMP_THRESHOLD
#define FSTRCMP_ERROR
int fstrcasecmpi(const char *string1, const char *string2);
DESCRIPTION
The fstrcmp() function compares the two strings, string1 and string2, ignoring case.
RETURN VALUE
The fstrcasecmpi function returns an int value between 0 and FSTRCMPI_IDENTICAL. A value of 0 means the strings are utterly un-alike. A
value of FSTRCMPI_IDENTICAL means the strings are identical. A value of more than FSTRCMPI_THRESHOLD (it lies between 0 and FSTRCMPI_IDEN-
TICAL) would be considered "similar" by most people.
A value of FSTRCMPI_ERROR (always negative) indicates a malloc(3) failure.
SEE ALSO fstrcasecmp(3)
fuzzy comparison of two strings ignoring case
fstrcmpi(3)
fuzzy comparison of two strings
COPYRIGHT
fstrcmp version 0.4
Copyright (C) 2009 Peter Miller
Peter Miller <pmiller@opensource.org.au>
The comparison code is derived from the fuzzy comparison functions in GNU Gettext 0.17. The GNU Gettext comparison functions were, in
turn, derived from GNU Diff 2.7.
Copyright (C) 1988-2009 Free Software Foundation
fstrcasecmpi(3)
I am writing a Shell Script. :)
Now i've problem in handling a string.
Eg: read string1
after i read in the string, i wan to add a space after it.
I've tried 1.) $string1 += " "
2.) string1 += " "
But both way cant works.
Does anyone got any idea how to solve my problem?... (2 Replies)
Hi,
I'm trying to egreg for a couple strings whcih are (0) and SYSTEM. The problem is the syntax for egreg is:
egreg "(string1|string2)"
With my basic knowledge of UNIX I don't know how to include '(0)' within "(string1|string2)" apart from trying to use single quotes which doesn't work,... (9 Replies)
i have textfiles that contain a series of lines that look like this:
string0 .................................................... column3a column4a
string1**384y0439 ..................................... column3b column4b... (2 Replies)
Hi,
i need to check my string1 is in another string2.
input_filename=017200910.DC30025
if
then
i need do some action
Can anyone tell me how to check my string is in another string.
example
i need to check .DC3 is in 017200910.DC30025 (5 Replies)
Hi everyone
I am very new at awk and to me the task I need to get done is very very challenging... Nevertheless, after admiring how fast and elegant issues are being solved here I am sure this is my best chance.
I have a 2D data file (input file is a plain tab-delimited text file). The first... (1 Reply)
I really need help in this :(
I have a file and would like to calculate the cosine similarity of the values in it...
For now I do use R which has an easy function for doing so
test <- as.matrix(read.csv(file="file.csv", sep=",", header=FALSE))
result<- cosine(t(test))
I am using unix of... (3 Replies)
Dear All,
I am facing a problem and I would be Thankful if you can help
Hope this is the right place to ask this question
I have two matrices of (row=10, col=3) and I want to get the cosine similarity between two lines (vectors) of each file --> the result should be (10,1) of cosine measures
I... (10 Replies)
Hi,
I have following codes which looks ok:
$ string1="123456789 abc2"
$ string2="abc"
$ position_of_string2=`expr index "$string1" "$string2"`
$ echo $position_of_string2
$
11however, when string2="abc2", it gives me the following result:
$ string1="123456789 abc2"
$... (5 Replies)
Hi
I have a set of input strings in a pattern as given below
string1 string2 string3 string4 string5
I need to search this sequence of strings from a file in such a way that the first two strings (string1 and string2) and last two strings (string4 and string5) should match with the... (8 Replies)
Hello,
My aim is to search string1 in all lines. When found, find and replace string2 by string3 if possible.
TextFile:
Here is my first line
Second line with string1 & string2
Not last line but it contains string1
Expected output:
Here is my first line
The second line with string1 &... (6 Replies)