Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey guys Im stuck at this task. Not to worry, I appreciate the job all of you wh

ID: 3632964 • Letter: H

Question

Hey guys

Im stuck at this task.
Not to worry, I appreciate the job all of you who help make and I'll rate anyone as helping me with lifesaver because that what you deserve.

Task:

Create a program that reads a text file. Pick out any (preferably unique) words in the text and write each word on a separate line to new file (dictionary.txt). Count and print the number of unique words. Make sure you take into account the various types of separators between the words as whitespace, periods, commas, etc. (Dots, commas and figures should not be included in the dictionary file). Use the open file dialog and appropriate menu option (Open / Save / Exit).
Use regular expressions.

This is the text what`s talking about:


Explanation / Answer

//DicttionaryGen.Designer.cs

namespace DictionaryGenerator
{
    partial class DicttionaryGen
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.mnuGenerate = new System.Windows.Forms.MenuStrip();
            this.generateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
            this.mnuGenerate.SuspendLayout();
            this.SuspendLayout();
            //
            // mnuGenerate
            //
            this.mnuGenerate.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.generateToolStripMenuItem});
            this.mnuGenerate.Location = new System.Drawing.Point(0, 0);
            this.mnuGenerate.Name = "mnuGenerate";
            this.mnuGenerate.Size = new System.Drawing.Size(284, 24);
            this.mnuGenerate.TabIndex = 0;
            //
            // generateToolStripMenuItem
            //
            this.generateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.openToolStripMenuItem,
            this.saveToolStripMenuItem,
            this.exitToolStripMenuItem});
            this.generateToolStripMenuItem.Name = "generateToolStripMenuItem";
            this.generateToolStripMenuItem.Size = new System.Drawing.Size(66, 20);
            this.generateToolStripMenuItem.Text = "&Generate";
            //
            // openToolStripMenuItem
            //
            this.openToolStripMenuItem.Name = "openToolStripMenuItem";
            this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.openToolStripMenuItem.Text = "&Open";
            this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
            //
            // saveToolStripMenuItem
            //
            this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
            this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.saveToolStripMenuItem.Text = "&Save";
            this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
            //
            // exitToolStripMenuItem
            //
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.exitToolStripMenuItem.Text = "&Exit";
            this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
            //
            // openFileDialog1
            //
            this.openFileDialog1.FileName = "untitled";
            this.openFileDialog1.Filter = "Text files|*.txt";
            this.openFileDialog1.InitialDirectory = "c:\";
            //
            // saveFileDialog1
            //
            this.saveFileDialog1.FileName = "dictionary.txt";
            this.saveFileDialog1.Filter = "Text Files|*.txt";
            //
            // DicttionaryGen
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(284, 262);
            this.Controls.Add(this.mnuGenerate);
            this.MainMenuStrip = this.mnuGenerate;
            this.Name = "DicttionaryGen";
            this.Text = "Form1";
            this.mnuGenerate.ResumeLayout(false);
            this.mnuGenerate.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.MenuStrip mnuGenerate;
        private System.Windows.Forms.ToolStripMenuItem generateToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
        private System.Windows.Forms.OpenFileDialog openFileDialog1;
        private System.Windows.Forms.SaveFileDialog saveFileDialog1;
    }
}

+++++++++++++++++++++++++++++++++++++++

//DicttionaryGen.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Text.RegularExpressions;
using System.IO;

namespace DictionaryGenerator
{
    public partial class DicttionaryGen : Form
    {
        public DicttionaryGen()
        {
            InitializeComponent();
        }

        String strInputContent = String.Empty;
        ArrayList lstDictionary = new ArrayList();

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName);
                strInputContent = sr.ReadToEnd().ToString();
                sr.Close();
                genDictionary();
            }
        }

        private void genDictionary()
        {
            Regex regex = new Regex(@"d+|s+|, +|,|. +|.");
            string[] result = regex.Split(strInputContent);
          
            foreach (string item in result)
            {
                if (!lstDictionary.Contains(item))
                {
                    lstDictionary.Add(item);
                }
            }
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            foreach (string item in lstDictionary)
            {
                sb.Append(item).Append(Environment.NewLine);
            }
            saveFileDialog1.ShowDialog();
            if (saveFileDialog1.FileName != "")
            {
                String name = saveFileDialog1.FileName;
                File.WriteAllText(name, sb.ToString());
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

++++++++++++++++++++++++++++++++

//Program.cs

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace DictionaryGenerator
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new DicttionaryGen());
        }
    }
}

I hope this helps your assignment.