<jupyter_start><jupyter_text>Messing with WordClouds using PowerShell> An example of creating and rendering word clouds in .NET Interative leveraging PowerShell and Markdown.- toc: false - badges: true- comments: true- image: images/copied_from_nb/dotnet-interactive.svg- categories: [jupyter, powershell, pswordcloud]  Install [PSWordCloud](https://github.com/vexx32/PSWordCloud) by [@vexx32](https://twitter.com/vexx32)<jupyter_code>Install-Module PSWordCloud -Force<jupyter_output><empty_output><jupyter_text>Create a word cloudFirst, let's grab the .NET Interactive codebase. That'll be what we make a word cloud out of.Get the zip, extract it and delete it:<jupyter_code>irm https://api.github.com/repos/dotnet/interactive/zipball -OutFile interactive.zip
try {
    Expand-Archive ./interactive.zip -Force
} finally {
    Remove-Item ./interactive.zip
}<jupyter_output><empty_output><jupyter_text>Get all of the files from the interactive folder, read their contents and craft a word cloud with it.<jupyter_code>Get-ChildItem -Recurse -File ./interactive/ | Get-Content | New-WordCloud -Path ./dotnet-interactive.svg<jupyter_output><empty_output><jupyter_text>Leveraging the `!markdown` magic command, we can render our new SVG:> NOTE: My blog mangles this path for some reason... the actual 'path' should just be `dotnet-interactive.svg`<jupyter_code>#!markdown

![.NET Interactive codebase word cloud](dotnet-interactive.svg)<jupyter_output><empty_output><jupyter_text>Create an in-memory word cloudsAs of PSWordCloud v3, you can output results directly into a variable using the variable provider:<jupyter_code>Get-ChildItem -Recurse -File ./interactive/ | Get-Content | New-WordCloud -Path variable:mySVG<jupyter_output><empty_output><jupyter_text>Then you can use that variable and pipe it directly into `Out-Display` to render the SVG! No file needed 😁<jupyter_code>$mySVG | Out-Display<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09911779968863518, 'fraction_numerical': 0.0036325895173845357, 'mean_word_length': 6.036496350364963, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '540094', 'license': 'Apache-2.0', 'n_tokens_mistral': 623, 'n_tokens_neox': 600, 'n_words': 177, 'path': '_notebooks/2020-03-16-Word-Clouds.ipynb', 'repo_name': 'TylerLeonhardt/blog', 'size': '1927'}