search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Text mining with PowerShell
Posted in Windows Powershell | No Comment | 2,555 views | 15/11/2014 10:37

This is a text mining example for PowerShell. You can export your Whatsapp conversations
to find out which words you used most.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$Contents = Get-Content Whatsapp.txt -Encoding UTF8
$TagCloud = @{"Whatsapp" = "1"}
$ChatArray = New-Object System.Collections.ArrayList
foreach ($Content in $Contents)
{
	$Words = $Content.Split(" ")
	foreach ($Word in $Words)
	{
		$Word = $Word.ToLower();
 
		if ($ChatArray.Contains($Word) -eq $True)
		{
			$TagCloud.($Word) = [int]$TagCloud.($Word)+1;
		}
		else
		{
			$AddArray = $ChatArray.Add("$Word")
			$TagCloud.($Word) = 1;
		}
	}
}
$TagCloud.GetEnumerator() | Sort-Object -Property Value -Descending

Then you can convert it to tag cloud by using public tag cloud services.



Leave a Reply