FastTrain comment

by yooakim at 2012-08-18 04:38:15

I really like your book! I have a minor question about the examples used for SlowTraing and FastTrain. in the loop there is this line:

$h[$word] += ‘’

Wouldn’t it make more sense to use this instead?

$h[$word] += 1

this would store the Count of occurrences for each word.

Cheers,
Joakim
by DougFinke at 2012-08-18 05:20:58
Thanks for getting the book Joakim. I’m glad you like it.

Really good question about the PowerShell Spelling Corrector.

My intention was to create a list of unique words that I could quickly look up. Knowing the number of occurrences of each word is not something that is needed for the spelling corrector application.

[size=125]You’ve hit on the next step![/size]
That PowerShell function is easily re-purposed and changed to do what you are suggesting.

Now you have a function that can take the content of any string or text file and it will count the number of occurrences of each word.

Thanks again for the great question.

Doug