Last active
August 29, 2015 14:11
-
-
Save Thorium/4ee6b0debdbcb9bddb7f to your computer and use it in GitHub Desktop.
Analyse word count from files. You can use it e.g. to create Tag Clouds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From NuGet: Sparc.TagCloud | |
#if INTERACTIVE | |
#r @"..\packages\Sparc.TagCloud.0.0.1\lib\net40\Sparc.TagCloud.dll" | |
#else | |
module MyTagCloud | |
#endif | |
open System.IO | |
open Sparc.TagCloud | |
let analyzer = new TagCloudAnalyzer() | |
let path = @"C:\sourcecodes\" | |
let extension = "*.cs" //e.g. c# files | |
let lines = | |
Directory.GetFiles(path, extension, SearchOption.AllDirectories) | |
|> Seq.map(fun i -> File.ReadAllLines(i)) | |
|> Seq.concat | |
let ``analyze and print`` = | |
analyzer.ComputeTagCloud(lines)//.Shuffle() | |
|> Seq.where(fun i -> i.Text.Length > 3) //over 3 letter words only... | |
|> Seq.take(50) //top 50 only... | |
|> Seq.iter(fun r -> printfn "%s\t%i" r.Text r.Count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment