Answers.Body: <p>With this data, a simple similarity measure that will find a high value between the pairs &quot;discuss&quot; and &quot;discussing&quot;, as well as between &quot;classic&quot; and &quot;classical&quot; can be the number of common characters from start divided by the root of the product of lengths. For the same words, similarity will be one, for words with no common prefix, zero. For close words such as the examples mentioned the value will be well above 1/2, useful enough for matching.</p>
  <p>Based on this similarity measure, Dynamic Time Warping should solve the problem.</p>
  <p>Or, instead of word alignment, character alignment with a simpler similarity function, 1 for equal characters, 0 for different. That would help align vIcTORY with crypTOgRaphY.</p>
  <p>I don't see much need for word embedding for this particular application. The only word equivalence not detected by blind character evaluation is &quot;stuff&quot;==&quot;things&quot;, but those words share three words on the left and two on the right, so they will be aligned anyway by a blind (and multilingual) method such as char-level DTW. Also, sentence splitting can be obtained as a byproduct of character alignment. Once aligned, the character zip can be cut where either thread has a point, or also a comma, if desired.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-26T09:02:48.683Z
Answers.LastActivityDate: 2023-01-26T12:07:13.363Z
Answers.LastEditDate: 2023-01-26T12:07:13.363Z
Answers.UserDisplayName: Jaume Oliver Lafont
Answers.Body: <p>First, you should first address the problem of 1. splitting sentences, and 2. the number of sentences in two texts. Then you can use a sentence embedding model and compare the similarity between the sentences in two sets of sentences.</p>
  <p>The easiest way could be averaging the ready-made word embedding vectors (<code>word2vec</code>, <code>fastText</code>, etc.) of all words in the sentence and using the resulting vector as the embedding vector for the sentence. Or you can use <code>Doc2Vec</code> directly on the sentences. Then you can use <code>cosine</code> as a similarity criterion between the sentence embedding vectors.</p>
  <p>Another easy way is to use the <code>BLEU</code> metric to compare the similarity of the sentences.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-26T08:17:44.300Z
Answers.LastActivityDate: 2023-01-26T08:49:07.303Z
Answers.LastEditDate: 2023-01-26T08:49:07.303Z
Answers.UserDisplayName: abbassix
Body: <p>Take this two texts as an example:</p>
  <blockquote>
  <p>&quot;I will start the recording and share the presentation. I hope it's
  all clear from what we saw last time on classical cryptography and if
  you remember we got to discussing perfect security. Ah, you're right,
  I didn't upload the slides. Wait, they are the same as last time. If
  you want to get the face on the fly, last time I mean last year. I had
  some things to do and didn't upload.&quot;</p>
  </blockquote>
  <blockquote>
  <p>&quot;Okay, I will start recording and I will share the presentation again.
  1, 0 So I hope it's all clear compared to what we saw last time about
  classic victory, And if you remember we got to let's say discuss the
  perfect security. Ah you could see already, I didn't upload the
  Slides, Wait they are the same as last time, Eh. If you want to have
  done on the fly, I mean last time, I mean from last year. Morning I
  had some stuff to do, I didn't upload.&quot;</p>
  </blockquote>
  <p>We want to align the sentences so that similar sentences (within a certain degree of difference) are being matched together.
  Which are the approaches to solve the issue?</p>
  <pre><code>[I will start the recording and share the presentation], 
  [I will start recording and I will share the presentation]
  
  
  [I hope it's all clear from what we saw last time on classical cryptography],
  [I hope it's all clear compared to what we saw last time about classic victory]
  
  [and if you remember we got to discussing perfect security],
  [And if you remember we got to let's say discuss the perfect security]
  .
  .
  .
  </code></pre>
  <p>I have been looking into DTW and perceptual hashing as a way to solve the problem without any concrete result then I saw that in the field of automatic translation sentence alignment is widely used but with the assumption that the two texts have different languages and that there is a one-to-one mapping between words without &quot;gaps&quot; or extra words in between.</p>
  
Tags: <natural-language-processing><machine-translation><text-detection>
Title: sentence alignment between same language texts
UserDisplayName: Axde
ThreadText: # sentence alignment between same language texts
  
  (Asked by: username_0 on 2023-01-26)
  
  Take this two texts as an example:
  
  > "I will start the recording and share the presentation. I hope it's
  > all clear from what we saw last time on classical cryptography and if
  > you remember we got to discussing perfect security. Ah, you're right,
  > I didn't upload the slides. Wait, they are the same as last time. If
  > you want to get the face on the fly, last time I mean last year. I had
  > some things to do and didn't upload."
  
  > "Okay, I will start recording and I will share the presentation again.
  > 1, 0 So I hope it's all clear compared to what we saw last time about
  > classic victory, And if you remember we got to let's say discuss the
  > perfect security. Ah you could see already, I didn't upload the
  > Slides, Wait they are the same as last time, Eh. If you want to have
  > done on the fly, I mean last time, I mean from last year. Morning I
  > had some stuff to do, I didn't upload."
  
  We want to align the sentences so that similar sentences (within a certain degree of difference) are being matched together.
  Which are the approaches to solve the issue?
  
  ```
  [I will start the recording and share the presentation], 
  [I will start recording and I will share the presentation]
  
  [I hope it's all clear from what we saw last time on classical cryptography],
  [I hope it's all clear compared to what we saw last time about classic victory]
  
  [and if you remember we got to discussing perfect security],
  [And if you remember we got to let's say discuss the perfect security]
  .
  .
  .
  
  ```
  
  I have been looking into DTW and perceptual hashing as a way to solve the problem without any concrete result then I saw that in the field of automatic translation sentence alignment is widely used but with the assumption that the two texts have different languages and that there is a one-to-one mapping between words without "gaps" or extra words in between.
  
  **Tags:** natural-language-processing, machine-translation, text-detection
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-01-26. Score: 1
  
  With this data, a simple similarity measure that will find a high value between the pairs "discuss" and "discussing", as well as between "classic" and "classical" can be the number of common characters from start divided by the root of the product of lengths. For the same words, similarity will be one, for words with no common prefix, zero. For close words such as the examples mentioned the value will be well above 1/2, useful enough for matching.
  
  Based on this similarity measure, Dynamic Time Warping should solve the problem.
  
  Or, instead of word alignment, character alignment with a simpler similarity function, 1 for equal characters, 0 for different. That would help align vIcTORY with crypTOgRaphY.
  
  I don't see much need for word embedding for this particular application. The only word equivalence not detected by blind character evaluation is "stuff"=="things", but those words share three words on the left and two on the right, so they will be aligned anyway by a blind (and multilingual) method such as char-level DTW. Also, sentence splitting can be obtained as a byproduct of character alignment. Once aligned, the character zip can be cut where either thread has a point, or also a comma, if desired.
  
  
  ---
  
  ### Answer by username_2 on 2023-01-26. Score: 1
  
  First, you should first address the problem of 1. splitting sentences, and 2. the number of sentences in two texts. Then you can use a sentence embedding model and compare the similarity between the sentences in two sets of sentences.
  
  The easiest way could be averaging the ready-made word embedding vectors (`word2vec`, `fastText`, etc.) of all words in the sentence and using the resulting vector as the embedding vector for the sentence. Or you can use `Doc2Vec` directly on the sentences. Then you can use `cosine` as a similarity criterion between the sentence embedding vectors.
  
  Another easy way is to use the `BLEU` metric to compare the similarity of the sentences.
  
  
  ---
  
  