With this AI_DICTIONARY ...
Code:
i fine
you fine
he fail
i good
she fine
Herman happy
Melvin euphoric
... this code ...
Code:
#dictation words variable
INPUT="i fine"
#convert to file with new lines instead of space
tr ' ' '\n' <$INPUT >$INPUT_TEST
#searches multiple lines for the most words in the input file and orders them
#ai dictionary can be a zeroed file for these purposes
grep -wFf $INPUT_TEST <$AI_DICTIONARY >$OutFile
... produced this OutFile ...
Code:
i fine
you fine
i good
she fine
With the same AI_DICTIONARY this code ...
Code:
#dictation words variable
INPUT="i fine"
#convert to variable with new lines instead of space
PROCESSED_INPUT=$(tr ' ' '|' <<<$INPUT)
#searches multiple lines for the most words in the variable and orders them
#ai dictionary can be a zeroed file for these purposes
egrep -w "($PROCESSED_INPUT)" <$AI_DICTIONARY >$OutFile
... produced the same OutFile.
If you care for a further refinement it is possible to eliminate the variable PROCESSED_INPUT.
With the same AI_DICTIONARY this code ...
Code:
#dictation words variable
INPUT="i fine"
#convert to variable with new lines instead of space
#searches multiple lines for the most words in the variable and orders them
#ai dictionary can be a zeroed file for these purposes
egrep -w "($(tr ' ' '|' <<<$INPUT))" <$AI_DICTIONARY >$OutFile
... produced the same OutFile.
Daniel B. Martin