I have two lists of words. The first one is the Master List. It contains the correct words in the correct order. The second lis is missing words and has a few out of order. But the numeric values in the second list has coordinates to where that word is located.
Here they are side by side:
{“IT”, {{“280”, “IT”},
“WAS”, {“449”, “WAS”},
“THE”, {“689”, “THE”},
“BEST”, {“959”, “BEST”},
“OF”, {“1360”, “OF”},
“TIMES”, {“1740”, “TIMES”},
“IT”,
“WAS”,
“THE”, {“2759”, “THE”},
“WORST”, {“2879”, “WORST”},
“OF”, {“3240”, “OF”},
“TIMES”, {“3379”, “TIMES”},
“IT”,
“WAS”, {“4420”, “WAS”},
“THE”, {“4509”, “THE”},
“AGE”, {“5239”, “WISDOM”},
“OF”, {“5440”, “OF”},
“WISDOM”} {“6190”, “AGE”}}
CONSTANTS: The first words of both lists will aways match.
THE OBJECTIVES: (1) Fill in the missing and out-of-order words. (2) Approximate the value of those missing words.
IMPORTANT: If words are out of order, it would be better to simply treat them as if they were missing. THE MASTER LIST IS THE CORRECT ORDER.
I know you can do this to get the boolean value comparing individual items:
item 2 of item 1 of theValsPhrase = item 1 of thePhrase
If the script somehow is able to determine where things are missing and how many items in a row are missing, a script like this could put the missing items in an approximate there values:
set thePhrase to {"IT", "WAS", "THE", "BEST", "OF", "TIMES", "IT", "WAS", "THE", "WORST", "OF", "TIMES", "IT", "WAS", "THE", "AGE", "OF", "WISDOM"}
set theValsPhrase to {{280, "IT"}, {449, "WAS"}, {689, "THE"}, {959, "BEST"}, {1360, "OF"}, {1740, "TIMES"}, {2759, "THE"}, {2879, "WORST"}, {3240, "OF"}, {3379, "TIMES"}, {4420, "WAS"}, {4509, "THE"}, {5239, "WISDOM"}, {5440, "OF"}, {6190, "AGE"}}
-- approximate the value of the first missing value for the first missing word
set x to (((item 1 of item 7 of theValsPhrase) - (item 1 of item 6 of theValsPhrase)) / 3)
set approxVal_01 to x + (item 1 of item 6 of theValsPhrase) as integer
set approxVal_and_Word_sublist to {approxVal_01 as list}
-- add the first missing word from the master list to the temp list
set end of item 1 of approxVal_and_Word_sublist to item 7 of thePhrase
-- approximate the value of the second missing value
set approxVal_02 to (item 1 of item 7 of theValsPhrase) - x as integer
set end of approxVal_and_Word_sublist to {approxVal_02}
-- add the second missing word
set end of item 2 of approxVal_and_Word_sublist to item 8 of thePhrase
-- put it all back together
set tempValsPhrase to items 1 thru 6 of theValsPhrase
set end of tempValsPhrase to approxVal_and_Word_sublist
set theValsPhrase to items 7 thru end of theValsPhrase
set theValsPhrase to tempValsPhrase & theValsPhrase
Any ideas or suggestions at where to start would be greatly appreciated.