I have a large paragraph, the part of which is near to(not always equivalent to) one given sentence. Now I want to find the position of this part.
For example, my paragraph is below (for convenience, I have deleted the punctuation marks and bold the part I wanted):
that expressed the same meaning like cold and chill heavy and weighty long and far What pair of synonyms created the obstacle to understanding you've just mentioned Think and say We've just learned to our surprise that they are not in fact synonyms They are not synonyms at all In our understanding they ought to be Think means using thought organs to conduct mental activity Say means communicating the content of thoughts to a counterpart The latter in your world is accomplished through the modulation of vibrations in the air produced by the vocal cords Are these definitions correct They are But doesn't this demonstrate that think and say aren't synonyms In our understanding this shows that they are synonyms May I think about this for a moment Very well We both need to think about it For two minutes Evans gazed in thought at the waves undulating beneath the starlight My Lord what are your organs of communication We do not have organs of communication Our brains can display our thoughts to the outside world thereby achieving communication Display thoughts How is that done The thoughts in our brains emit electromagnetic waves on all frequencies including what is visible light to us They can be displayed at a significant distance So that means that to you thinking is speaking Hence they are synonyms
The sentence is:
is accomplished through the modulation of vibrations in the air produced by the vocal courts are these definitions correct they are
We can see that the word counts
is replaced by cords
in the paragraph, which is bolded by me. And I want to find the position of the first word is
, such as the 81st word in the paragraph(I used a Position[StringSplit@#,"is"]
) or the percentage.
Obviously I cannot just use StringContainQ
function or so, and replacement is just one of possible cases, including lacking or adding some words. And one cannot first split the sentence to small ones and then use StringContainQ
as there may be repeated part in the paragraph, so the sentence itself need to be properly longer. My idea is to write a function which can estimate the “distance” between the two strings, and find the nearest in the large paragraph. But I don't have a farther idea...
PS: The large paragraph is actually a long novel, and the sentence is the result of SpeechRecognize
function at a part of an audio of the novel, so there are inevitable differences between them. My task is to make a one-to-one correspondence between them(the sentence and the position of it in the novel).
para = "that expressed the same meaning like cold and chill heavy and weighty long and far What pair of synonyms created the obstacle to understanding you've just mentioned Think and say We've just learned to our surprise that they are not in fact synonyms They are not synonyms at all In our understanding they ought to be Think means using thought organs to conduct mental activity Say means communicating the content of thoughts to a counterpart The latter in your world is accomplished through the modulation of vibrations in the air produced by the vocal cords Are these definitions correct They are But doesn't this demonstrate that think and say aren't synonyms In our understanding this shows that they are synonyms May I think about this for a moment Very well We both need to think about it For two minutes Evans gazed in thought at the waves undulating beneath the starlight My Lord what are your organs of communication We do not have organs of communication Our brains can display our thoughts to the outside world thereby achieving communication Display thoughts How is that done The thoughts in our brains emit electromagnetic waves on all frequencies including what is visible light to us They can be displayed at a significant distance So that means that to you thinking is speaking Hence they are synonyms";
sen = "is accomplished through the modulation of vibrations in the air \
produced by the vocal courts are these definitions correct they are";
SequenceAlignment[para, sen, Method -> "Local", IgnoreCase -> True]
could be a starting point. $\endgroup$