Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Possible approach:</p> <p>Construct a Dictionary with a string key of "word1|word2" for all combinations of words in the <em>reference</em> string. A single combination may happen multiple times, so the value of the Dictionary should be a <em>list</em> of numbers, each representing the <em>distance</em> between the words in the reference string.</p> <p>When you do this, there will be duplication here: for every "word1|word2" dictionary entry, there will be a "word2|word1" entry with the same list of distance values, but negated.</p> <p>For each combination of words in the <em>comparison</em> string (words 1 and 2, words 1 and 3, words 2 and 3, etc.), check the two keys (word1|word2 and word2|word1) in the reference string and find the <em>closest</em> value to the distance in the current string. Add the absolute value of the difference between the current distance and the closest distance to a counter.</p> <p>If the closest reference distance between the words is in the opposite direction (word2|word1) as the comparison string, you may want to weight it smaller than if the closest value was in the same direction in both strings. </p> <p>When you are finished, divide the sum by the square of the number of words in the comparison string.</p> <p>This should provide some decimal value representing how closely each word/phrase matches some word/phrase in the original string.</p> <p>Of course, if the original string is longer, it won't account for that, so it may be necessary to compute this both directions (using one as the reference, then the other) and average them.</p> <p>I have absolutely no code for this, and I probably just re-invented a very crude wheel. YMMV.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload