I have two lists of strings like this:
list1={"a dog is in the house","have a nice day","hello my friend"};
list2={"a dog is in house","watching tv is nice","hello my friends"};
Now i want to use SmithWatermanSimilarity
to check for similarity like this: For each element in list1 check if there are similar elements in list2 (by defining a threshold value for SmithWatermanSimilarity
e.g. the value should be higher than 0.9 of StringLenght
or so)
The desired output should be a list like this:
list3={{"a dog is in the house","a dog is in house"},{"have a nice day"},{"hello my friend","hello my friends"}};
I already found a rough solution which uses a combination of If
and two nested Table
but this seems to me a little bit clumsy one...
Table[Table[
If[SmithWatermanSimilarity[list1[[x]],
list2[[y]]] > (StringLength[list1[[x]]]*0.8), {list1[[x]],
list2[[y]]}, list1[[x]]], {x, 1, Length[list1]}], {y, 1,
Length[list2]}]