Giter VIP home page Giter VIP logo

nonsensecreator's Introduction

NonsenseCreator

Iron Scripter Challenge

Module to create nonsense words, sentences, paragraphs, and documents. Allows for adding markdown formatting as well. Challenge at https://ironscripter.us/a-powershell-nonsense-challenge/

Solution Goals

  • Generate a word that has a 75% chance of alternating from vowel to consonant at each letter.
  • Generate a sentence, paragraph, or document using words with the aforementioned function.
  • Generate markdown formatted document.
  • Include diacritics option
  • Include word length, sentence length, paragraph length, and document length options

Solution method

Use object classes for vowel, consonant, special characters, and connecting punctuation. The nonsensical words are generated with the letters having a 75% chance of alternating from vowel to consonant and back to flow better if actually read. When creating a document, first generate a word list with nearly twice as many words as the word count given or the word count randomly chosen by the function. This will cause the document to repeat words, which I believe is easier on the eyes at a glance and makes the document build faster.

Example Word List Code

    $WordList = (1..($WordCount * 2) | 
    ForEach-Object -Process {New-NonsenseWord -IncludeDiacritics}) | 
    Select-Object -Unique |
    Select-Object -First $WordCount

Example Object Class

    class Vowel
    {
        [char]$Letter
        hidden [int]$Int
        hidden [bool]$Uppercase
        hidden [int[]]$PossibleInts = 97,101,105,111,117,121

        Vowel()
        {
            $this.Letter = [char]$($this.PossibleInts | Get-Random)
        }
    }

Functions

  • New-NonsenseWord -- Uses the object class types to generate random words -- Offers length and diacritics options
  • New-NonsenseSentence -- Calls the New-NonsenseWord function -- Offers length, diacritics, and word list options
  • New-NonsenseParagraph -- Calls the New-NonsenseSentence function -- Offers sentence count, diacritics, and word list options
  • New-NonsenseDocument -- Requires a path for the output file -- Offers diacritics, word count, and markdown optiosn

Object Classes

  • Vowel
  • Consonant
  • Punctuation
  • SpecialCharacter

nonsensecreator's People

Contributors

rgroefer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.