CURRENT STATUS: The forums you are now looking at are CLOSED. Visit the new forums.


FastTrain comment

Creating PowerShell extensions in Visual Studio? Post here! Monitored by MVP Doug Finke.
Forum rules
1. Use the CODE or POWERSHELL buttons to format code and commands.
2. Avoid the use of obscure and punctuation aliases (like ? and %).
3. Don't apologize for being a "noob." We don't mind.
4. If we help you solve your question, please click the green SOLVED checkmark.

More forums tips & etiquette

FastTrain comment

Postby yooakim » Sat Aug 18, 2012 12:38 pm

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:

Code: Select all
 $h[$word] += ''


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

Code: Select all
 $h[$word] += 1


this would store the Count of occurrences for each word.

Cheers,
Joakim
yooakim
 
Posts: 23
Joined: Wed Aug 15, 2012 9:10 am

Re: FastTrain comment

Postby DougFinke » Sat Aug 18, 2012 1:20 pm

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.

You've hit on the next step!
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
Doug's Book | Doug's Blog | PowerShell MVP
User avatar
DougFinke
MVP
MVP
 
Posts: 11
Joined: Mon Aug 13, 2012 1:24 pm
Location: New York City


Return to PowerShell for Developers

Who is online

Users browsing this forum: No registered users and 1 guest