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:
- 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
- Using LCS and Levenshtein Distance. But I was able to extract only a part of string.