Compute a frequency distribution of the meaningful words from any text file and create a personal graphical representation
5_A assignament
Request
Compute - in both languages C# and VB.NET (and optionally in js) - a frequency distribution of the meaningful words from any text file and create a personal graphical representation of the corresponding “word cloud” (in case, can use animation if you wish), keeping into account the frequencies of the words.
publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}SortedDictionary<String,int>wDstr=newSortedDictionary<string,int>();privatevoidForm1_Load(objectsender,EventArgse){}privatevoidbutton1_Click(objectsender,EventArgse){varfilePath=string.Empty;openFileDialog1.InitialDirectory="c:\\";openFileDialog1.Filter="txt files (*.txt)|*.txt|All files (*.*)|*.*";openFileDialog1.FilterIndex=2;openFileDialog1.RestoreDirectory=true;openFileDialog1.Title="Select Text File";if(openFileDialog1.ShowDialog()==DialogResult.OK){//Get the path of specified file
filePath=openFileDialog1.FileName;//Read the contents of the file into a stream
using(StreamReadersr=newStreamReader(filePath)){while(sr.Peek()>=0){stringline=sr.ReadLine();char[]delimiters=newchar[]{' ','\r','\n'};string[]words=line.Split(delimiters,StringSplitOptions.RemoveEmptyEntries);inti=0;foreach(stringwordinwords){if(!wDstr.TryGetValue(word,outi))wDstr.Add(word,1);else{wDstr.Remove(word);i++;wDstr.Add(word,i);}}}}intj=0;foreach(varwinwDstr){chart1.Series["Words"].Points.AddXY(w.Key,w.Value);}}}}