示例#1
0
    private void btnWordContext_Click(object sender, EventArgs e)
    {
        if (lstBigDataOutput.SelectedIndex == -1)
        {
            ShowMessage("Please Select a Term");
            return;
        }

        btnWordContext.Enabled = false;

        string word = (string)lstBigDataOutput.Items[lstBigDataOutput.SelectedIndex];

        word = word.Substring(0, word.IndexOf(' '));

        clsFoundTerm sTerm = new clsFoundTerm();

        foreach (clsFoundTerm term in foundTerms)
        {
            if (term.Term == word)
            {
                sTerm = term;
                break;
            }
        }

        ArrayList fTerms = new ArrayList();

        foreach (clsFoundTerm term in foundUniqueTerms)
        {
            if (term.Term == sTerm.Term)
            {
                fTerms.Add(term);
            }
        }

        foreach (clsFoundTerm term in fTerms)
        {
            lstWordContext.Items.Add((string)sentences[term.SentNum]);
        }
    }
示例#2
0
    private void btnRemoveTerm_Click(object sender, EventArgs e)
    {
        bool isListed = false;

        if (lstBigDataOutput.SelectedIndex == -1)
        {
            ShowMessage("Please Select a Term");
            return;
        }

        string word = (string)lstBigDataOutput.Items[lstBigDataOutput.SelectedIndex];

        word = word.Substring(0, word.IndexOf(' '));

        clsFoundTerm sTerm = new clsFoundTerm();

        foreach (clsFoundTerm term in foundTerms)
        {
            if (term.Term == word)
            {
                sTerm = term;
                break;
            }
        }

        foreach (string term in badTerms)
        {
            if (sTerm.Term == term)
            {
                isListed = true;
                break;
            }
        }

        if (!isListed)
        {
            badTerms.Add(sTerm.Term);
        }
    }
示例#3
0
    private void DisplayOutput()
    {
        lstBigDataOutput.Items.Clear();

        ArrayList tempData = new ArrayList();

        foreach (clsFoundTerm item in foundTerms)
        {
            tempData.Add(item);
        }

        //Basic Sort Structure
        if (sortNum)
        {
            if (sortNumHigh)
            {
                for (int i = 0; i < tempData.Count - 2; i++)
                {
                    for (int n = i + 1; n < tempData.Count - 1; n++)
                    {
                        clsFoundTerm first      = (clsFoundTerm)tempData[i];
                        clsFoundTerm second     = (clsFoundTerm)tempData[n];
                        int          firstTerm  = first.Count;
                        int          secondTerm = second.Count;

                        if (firstTerm < secondTerm)
                        {
                            clsFoundTerm temp = (clsFoundTerm)tempData[i];
                            tempData[i] = second;
                            tempData[n] = temp;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < tempData.Count - 2; i++)
                {
                    for (int n = i + 1; n < tempData.Count - 1; n++)
                    {
                        clsFoundTerm first      = (clsFoundTerm)tempData[i];
                        clsFoundTerm second     = (clsFoundTerm)tempData[n];
                        int          firstTerm  = first.Count;
                        int          secondTerm = second.Count;

                        if (firstTerm > secondTerm)
                        {
                            clsFoundTerm temp = (clsFoundTerm)tempData[i];
                            tempData[i] = second;
                            tempData[n] = temp;
                        }
                    }
                }
            }
        }
        else if (sortWord)
        {
            if (sortWordAsc)
            {
                for (int i = 0; i < tempData.Count - 2; i++)
                {
                    for (int n = i + 1; n < tempData.Count - 1; n++)
                    {
                        clsFoundTerm first      = (clsFoundTerm)tempData[i];
                        clsFoundTerm second     = (clsFoundTerm)tempData[n];
                        string       firstTerm  = first.Term;
                        string       secondTerm = second.Term;

                        if (firstTerm.CompareTo(secondTerm) < 0)
                        {
                            clsFoundTerm temp = (clsFoundTerm)tempData[i];
                            tempData[i] = second;
                            tempData[n] = temp;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < tempData.Count - 2; i++)
                {
                    for (int n = i + 1; n < tempData.Count - 1; n++)
                    {
                        clsFoundTerm first      = (clsFoundTerm)tempData[i];
                        clsFoundTerm second     = (clsFoundTerm)tempData[n];
                        string       firstTerm  = first.Term;
                        string       secondTerm = second.Term;

                        if (firstTerm.CompareTo(secondTerm) > 0)
                        {
                            clsFoundTerm temp = (clsFoundTerm)tempData[i];
                            tempData[i] = second;
                            tempData[n] = temp;
                        }
                    }
                }
            }
        }
        else
        {
            //Displays no sort or limit
        }

        for (int i = 0; i < foundTerms.Count; i++)
        {
            clsFoundTerm temp = (clsFoundTerm)tempData[i];

            lstBigDataOutput.Items.Add(temp.Term.PadRight(50) + temp.Count.ToString().PadLeft(5));
        }
    }
示例#4
0
    //Buttons

    private void btnAnalyze_Click(object sender, EventArgs e)
    {
        string rawData = txtInput.Text;

        foundTerms.Clear();
        foundUniqueTerms.Clear();

        #region TermLocation
        sentences  = new ArrayList();
        paragraphs = new ArrayList();

        if (rawData.Trim() == "")
        {
            ShowMessage("Please provide text for user input.");
            txtInput.Focus();
            return;
        }

        string[] p = rawData.Split('\n');

        int sNum = 0;
        int pNum = 0;

        foreach (string para in p)
        {
            paragraphs.Add(para);

            string[] s = Regex.Split(para, @"(?<=[\.!\?])\s+"); // Courtesy: http://stackoverflow.com/questions/4957226/split-text-into-sentences-in-c-sharp

            foreach (string sent in s)
            {
                sentences.Add(sent);

                string[] rawTerms = sent.Split(' ');

                foreach (string term in rawTerms)
                {
                    if (CheckLength(term))
                    {
                        string word  = RemoveEncapsulation(term);
                        string tWord = term;

                        while (word != tWord)
                        {
                            tWord = word;
                            word  = RemoveEncapsulation(word);
                        }

                        word = NormalizeTerm(word);

                        if (!CompareTerm(word, sNum, pNum))
                        {
                            clsFoundTerm temp = new clsFoundTerm(word, sNum, pNum);
                            foundUniqueTerms.Add(temp);
                        }
                    }
                }

                sNum++;
            }

            pNum++;
        }
        #endregion

        #region TermCount
        rawData = RemoveNewLineChars(rawData);

        string[] rawTerm = rawData.Split(' ');

        foreach (string term in rawTerm)
        {
            if (CheckLength(term))
            {
                string word  = RemoveEncapsulation(term);
                string tWord = term;

                while (word != tWord)
                {
                    tWord = word;
                    word  = RemoveEncapsulation(word);
                }

                word = NormalizeTerm(word);

                if (!CompareTerm(word))
                {
                    clsFoundTerm temp = new clsFoundTerm(word);
                    foundTerms.Add(temp);
                }
            }
        }
        #endregion

        listBoxItems = foundTerms;

        DisplayOutput();

        btnSearch.Enabled     = true;
        btnAddTerm.Enabled    = true;
        btnRemoveTerm.Enabled = true;
        btnAnalyze.Enabled    = false;

        txtInput.Clear();
    }