0

For example:

string1 = 
  "Sherlock Holmes is a fictional private detective created by British author Sir Arthur Conan Doyle. Known as a consulting detective in the stories, Holmes is known for his proficiency with observation."

string2 = 
  "fictional detective created by British author Conan Doyle. Also, known as a consulting detective"

I want to extract an approximate match to string2 from string1. Result should be:

"fictional private detective created by British author Sir Arthur Conan Doyle. Known as a consulting detective"

Things I have tried:

  1. Split sentence into array and extract the string between first and last word. But this solution fails if the first or last word itself does not exist in string1
  2. Using LCS and Levenshtein Distance. But I was able to extract only a part of string.
Gary
  • 13,303
  • 18
  • 49
  • 71
VinodJM
  • 1
  • 2
  • what's you definition of a "matching string"? If your using fuzzy logic you need to define somekind of success parameters – Liam Sep 22 '17 at 13:26
  • In result string, you took `Sir` from string1 but you didn't take `Sherlock Homes is a` from string1? Any reason? – Lali Sep 22 '17 at 13:26
  • @Lali: Because the second string starts from fictional, so I don't need Sherlock Holmes. My documents are unstructured documents, so I cannot split by "." – VinodJM Sep 22 '17 at 13:30
  • @Liam:Basically it has to extract all the words from string1 between the first and last word of string2. But how can I extract when first or last word of string 2 does not exist in string 1. – VinodJM Sep 22 '17 at 13:33

0 Answers0