1.

Solve : batch predict next word?

Answer»

hi...

how to make batch script to predict next word???

for example i enter a word "wash"...and batch show next word "the" and "car" and so much more

exp-

set /p input=Enter the word :
type %input%

>wash

1. the ( 60% )
2. my ( 25% )
3. yours ( 15 %)

and enter number to choose option
if i choose no.1

echo wash the

and predict next word after "the"

>the

1. car ( 55% )
2. bus (35% )
3. feet (10% )

and more...

i already create combination word
"wash the" pwashthe=5
"wash my" pwashmy=3
"wash your" pwashyour=1
"the car" pthecar=4
"the bus" pthebus=3
"the feet" pthefeet=1

set wash as oldword

and i try to make batch show %nextword%

i dont know some one can understand my poor explaination or not...
i hope somebody COULD...

i need suggestion that could help...ty

This does sound like too much for Batch - Batch is designed for small SCRIPTS to automate COMMON tasks, this is a much more complex project that will really need a full programming language.

That said what you would likely need to do (For the simplest version of this) would be to have a large library of text e.g. the contents of a book stored somewhere, you would then need to scan this for all the words that follow the word you are looking for, Order these words by the number of times they appear and then return the top 3.

I'm really not sure if something like this is even possible in batch, it certainly won't be pretty or fast. You'd really be best to consider using a full programming language like Java/C/Python/Perl.etc - You may be able to get more help with this in our programming section.It is "possible" but I would use a different language for this. Using the same process here is how you would return the top three (with the library setup "word" > word1 > word list (.txt) [all containing their likelihood to follow word1)
Code: [SELECT]setlocal EnableDelayedExpansion
for /f "delims=" %%A in ('dir /b /a:d "%~pd0\word"') do (
for /f "delims=" %%B in ('dir /b /a:-d "%~pd0\word\%%A"') do (
set /p working=<%~pd0\word\%%A\%%B.txt
if not exist tmp md tmp
echo %%B >>"%~pd0\tmp\!working!.txt"
)
)

:: Then all the words with the highest chance at comming next will be on the top in %~pd0\tmp inside the organized text file
:: To read them, you do

set READTO=3
for /f "delims=" %%A in ('dir /b "%~pd0\tmp') do (
if not !toread! LSS 0 (
set /p working=<%~pd0\tmp\%%A
echo !working! >>top3.txt
set /a toread-=1
if !toread! LSS 0
)
)


Keep in mind that none of this code is tested, and is not guaranteed to work.



Discussion

No Comment Found