Skip to content

Instantly share code, notes, and snippets.

@tjgruber
Created February 2, 2021 10:03
Show Gist options
  • Save tjgruber/0a2121b4c785b7f844d2d2aed1fbb0d1 to your computer and use it in GitHub Desktop.
Save tjgruber/0a2121b4c785b7f844d2d2aed1fbb0d1 to your computer and use it in GitHub Desktop.
Iron Scripter - Scripting Challenge Meetup
$helpTopic = "about_Splatting"
$excludedWords = "the"
$words = ((Get-Help $helpTopic) -replace "[^\w]"," " -replace "\d"," " -replace '_'," " -split " ") | Where-Object {$_ -ne ""}
$sortedWords = $words | Group-Object | Sort-Object -Property Count -Descending | Where-Object -Property Name -NE $excludedWords
[PSCustomObject]@{
'Help Topic Name' = $helpTopic
'Word Count' = $words.Count
'Top Word' = ($sortedWords | Select-Object -First 1).Name
'Top Word Count' = ($sortedWords | Select-Object -First 1).Count
'Top 5 Words' = ($sortedWords | Select-Object -First 5).Name -join ", "
}
@tjgruber
Copy link
Author

tjgruber commented Feb 2, 2021

OUTPUT: (IronScripter-ScriptingChallengeMeetup.ps1)

Help Topic Name : about_Splatting
Word Count      : 1453
Top Word        : a
Top Word Count  : 46
Top 5 Words     : a, to, in, parameter, parameters

Just to verify my word count is close:
(Get-Help $helpTopic | Measure-Object -Word).Words

Output:

1454

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment