# Search-Dictionary Powershell Module

By
,
Powershell
,
Modules
Published 2022-08-17

Link To Download Search-Dictionary Module
https://www.powershellgallery.com/packages/Search-Dictionary/1.0

Imagine if we lived in todays world without technology. We might have to read the dictionary to pass the time
Imagine if we lived in todays world without technology. We might have to read the dictionary to pass the time

# Powershell Function 📖

Yep same story been looking at existing public APIs out there that require no authentication or key to be used. I then stumbled across this website:-

The API I am using
https://dictionaryapi.dev/

Again I built this module because when checking the powershell gallery for dictionary I was not getting any results returned back to me. So I thought it would be a good idea to bring a built in Powershell dictionary I could use directly from the shell.

I know this is not a spell-checker so I did build in some basic error handling on the module to give you a meaningful error message should there be an issue with the word you are trying to search for.

As you may have noticed but I like to use a lot of comic pictures in my blogs from comics I have read. Well just so happens I also know some real-life super-heroes. You do not believe me?

A certain paladin I know actually owns this impeccable machine of fascination
A certain paladin I know actually owns this impeccable machine of fascination

Just in-case you missed the last blog, or you are just reading particular blogs, or this could possile be your first blog let us just quickly go over an API again...Please skip if this if you already read it in the last blog...or previous blog to that.

# API ℹ️

You may or may not know about API aka Application Programming Interface. So here is some brief documentation

API An application programming interface is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build or use such a connection or interface is called an API specification. A computer system that meets this standard is said to implement or expose an API. The term API may refer either to the specification or to the implementation. In contrast to a user interface, which connects a computer to a person, an application programming interface connects computers or pieces of software to each other. It is not intended to be used directly by a person other than a computer programmer who is incorporating it into the software. An API is often made up of different parts which act as tools or services that are available to the programmer

So come on Adam what does that mean in cave man talk. Well to a simple person like me it would be like going to a McDonalds drive through with no queue and everything just waiting to be given to you. Still not making sense? Okay to me it is the fastest way you can possible achieve the specific answer you are looking for. So yeah maybe I could have downloaded some software to run this for me, but trust unless the program is using an API then this will give you results quicker than the program could. Or like if I was to do this manually, just the processing power and memory that firefox.exe uses on my laptop, it would be slower going via the web than it would for me to make the API call, the result is instant. I know not everyone out there has a 10 year old crappy x86 laptop to do all this experimenting on, but trust if it runs super fast on my laptop (which it does) it should be lightning fast on your nice x64 solid state drive stupid amount of ram machine. In a nutshell that is why to use an API for the task, and secondly to my knowledge APIs are normally only serving one purpose to keep them super fast. By one purpose I mean an API to find train times...It is not going to tell you what the weather will be like, or the services available on each train, it will just give you train times. I hope this paragraph has maybe made more sense than the official wiki guide above.

# Search-Dictionary 📓

The Dark Age where a modern world is rid of technology another great read
The Dark Age where a modern world is rid of technology another great read

This time I went to the approved verb documentation, and for me this in my head I want to search the dictionary. I mean I could have done Find-Word but I wanted to let the user know they are using a dictionary, and Find-Dictionary to me sounds like I am looking for a dictionary. Hence I went with Search-Dictionary as I am finding a word (object) in a dictionary (container) at least that is how I justified this Search verb I used.

Find vs. Search Use the Find verb to look for an object. Use the Search verb to create a reference to a resource in a container.

Remember if you are unsure of what verb you can use, or what verb you should use, then please check out the link below for full explanation.

Approved Verb Documentation
https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands?view=powershell-7.2

# Top Tip Add Decent Help 📝

Good news, the heat-wave has finally stopped so no excuses for not writing some decent help the first time round. This is the help synopsis I wrote for this particular module.

NAME
    Search-Dictionary

SYNOPSIS
    Displays information on a given word from the dictionary


SYNTAX
    Search-Dictionary [-Word] <String> [<CommonParameters>]


DESCRIPTION
 This uses dictionaryapi.dev to obtain the information displayed to you. To my knowledge no dictionary checkers are available as a module on the Powershell Gallery, due to my fondness of the English language and always looking for the most appropriate word to use, I thought creating a module to do just that would be a jolly good idea. This will return the definition of the word, an example of using the word, an audio clip of the phonetics of the word and finally a web link to wiktionary.org to 
find out even more information on this word you search for. Not every result contains examples and audio.


PARAMETERS
    -Word <String>
        This is a single string word. So no need for speech-marks when using this parameter if you do not wish to do
        so. A single string
        is specified as the word to search. Like if you wanted to know about the word barbaric then use -Word Barbaric
        as the string to
        pass as the parameter.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS

    -------------------------- EXAMPLE 1 --------------------------

    PS > Search-Dictionary -Word facetious

    You searched for the word:- facetious

    The definition of facetious is:- Treating serious issues with (often deliberately) inappropriate humour; flippant.
    Pleasantly hum
    orous; jocular.

    An example of facetious would be:- Robbie's joke about Heather's appearance was just him being facetious.

    Phonetics of this word can be listened to here:- https://commons.wikimedia.org/w/index.php?curid=11518620

    To find out more about facetious go check out:- https://en.wiktionary.org/wiki/facetious




    -------------------------- EXAMPLE 2 --------------------------

    PS > Search-Dictionary -Word ostentatious

    You searched for the word:- ostentatious

    The definition of ostentatious is:- Of ostentation. Intended to attract notice. Of tawdry display; kitsch.

    An example of ostentatious would be:-

    Phonetics of this word can be listened to here:-

    To find out more about ostentatious go check out:- https://en.wiktionary.org/wiki/ostentatious

# I hope you had fun 👋

Hopefully this module will make you think about what you can do with an API. As always I like to try and keep things interesting, and to try and make something unique and useful as the end module product.

Me riding off into the sunset after making another module to make the world a better place
Me riding off into the sunset after making another module to make the world a better place