Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created February 15, 2014 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfinke/9020857 to your computer and use it in GitHub Desktop.
Save dfinke/9020857 to your computer and use it in GitHub Desktop.
function Invoke-Thesaurus {
param(
$Word='Thesaurus',
$FilterCategory
)
$language='en_US'
$key='<get key here http://thesaurus.altervista.org/mykey>'
$result="json"
$endpoint = "http://thesaurus.altervista.org/thesaurus/v1?word=$word&language=$language&key=$key&output=$result"
$(
ForEach($item in (Invoke-RestMethod $endpoint).response.list) {
ForEach($synonym in $item.synonyms.split('|')) {
[pscustomobject]@{
Word = $Word
Synonym = $synonym -replace "\(similar term\)",""
Category = $item.Category -replace "\(|\)",""
}
}
}
) | where {$_.Category -match $FilterCategory}
}
function DoCombination {
param($word1, $word2)
$l1=Invoke-Thesaurus $word1
$l2=Invoke-Thesaurus $word2
foreach($item1 in $l1) {
foreach($item2 in $l2) {
"{0} {1}" -f $item1.Synonym,$item2.Synonym
}
}
}
DoCombination value proposition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment