private void findPeak()
        {
            int    percent = Convert.ToInt32(partTextBox.Text);
            double part    = (double)percent / 100;
            Dictionary <string, int> peaks = new Dictionary <string, int>();
            DataTable peaksDestr           = new DataTable();

            peaksDestr.Columns.Add(new DataColumn("НормФорма"));
            peaksDestr.Columns["НормФорма"].DataType = typeof(string);
            peaksDestr.Columns.Add(new DataColumn("ПредложенияПика"));
            peaksDestr.Columns["ПредложенияПика"].DataType = typeof(string);
            for (int i = 0; i < destributionTable.RowCount * part; i++)
            {
                Parameters param = new Parameters();
                param.word = destributionTable.Rows[i].Cells[0].Value.ToString();
                GetSentForSelectedWord sentFreq = new GetSentForSelectedWord(MainForm.BDLocation, MainForm.tableName, param);
                int     partition = MainForm.sentCount / 10;
                int[]   frqMas    = sentFreq.GetFreqDestribution(sentFreq, MainForm.sentCount, partition);
                int     maxIndex  = peaks[param.word] = Array.IndexOf(frqMas, frqMas.Max());
                DataRow row       = peaksDestr.NewRow();
                row["НормФорма"]       = param.word;
                row["ПредложенияПика"] = (maxIndex * 10).ToString() + "-" + ((maxIndex + 1) * 10).ToString();
                peaksDestr.Rows.Add(row);
            }
            DataSet ds = new DataSet();

            ds.Tables.Add(peaksDestr);
            TerminSurroundingsForm form = new TerminSurroundingsForm(ds);

            form.Show();
        }
示例#2
0
        public int[] GetFreqDestribution(GetSentForSelectedWord ts, int sentBegin, int sentCount, int partitionCount)
        {
            DataRowCollection rows = ts.dataSet.Tables[0].Rows;

            int[] frqMas = new int[partitionCount];
            int   k      = 0;

            //        wordSentCount = rows.Count;
            for (int j = 0; j < rows.Count; j++)
            {
                if (Convert.ToInt32(rows[j][1]) >= sentBegin && Convert.ToInt32(rows[j][1]) < sentBegin + sentCount)
                {
                    while (Convert.ToInt32(rows[j][1]) > (k + 1) * (sentCount / partitionCount) + sentBegin)
                    {
                        k++;
                    }
                    if (k == partitionCount)
                    {
                        frqMas[k - 1] += 1;
                    }
                    else
                    {
                        frqMas[k] += 1;
                    }
                }
            }
            return(frqMas);
        }
        private void findPeaksButton_Click(object sender, EventArgs e)
        {
            //GraphPane pane = new GraphPane(new RectangleF(1, 1, 300, 300), "", "Предложения", "Частота встречаемости");
            //PointPairList list = new PointPairList();
            //double xmin = -1;
            //double xmax = 1;

            //// Заполняем список точек
            //for (double x = xmin; x <= xmax; x++)
            //{
            //    // добавим в список точку
            //    list.Add(x, x);
            //}

            //// Создадим кривую с названием "Sinc",
            //// которая будет рисоваться голубым цветом (Color.Blue),
            //// Опорные точки выделяться не будут (SymbolType.None)
            //LineItem myCurve = pane.AddCurve("Sinc", list, Color.Blue, SymbolType.None);

            //// Вызываем метод AxisChange (), чтобы обновить данные об осях.
            //// В противном случае на рисунке будет показана только часть графика,
            //// которая умещается в интервалы по осям, установленные по умолчанию
            //Z.AxisChange();

            //// Обновляем график
            //zedGraph.Invalidate();
            int    percent = Convert.ToInt32(partTextBox.Text);
            double part    = (double)percent / 100;
            //    Dictionary<string, int[]> wordsFreqs = new Dictionary<string, int[]>();
            GraphForm form = new GraphForm();

            for (int j = 0; j < destributionTable.RowCount * part; j++)
            {
                Parameters param = new Parameters();
                param.word = destributionTable.Rows[j].Cells[0].Value.ToString();
                GetSentForSelectedWord sentFreq = new GetSentForSelectedWord(MainForm.BDLocation, MainForm.tableName, param);
                int[] frqMas = sentFreq.GetFreqDestribution(sentFreq, MainForm.sentCount, 10);
                //        wordsFreqs.Add(param.word, frqMas);
                form.drawGraph(param.word, frqMas);
                break;
            }
            form.Show();
            //foreach (KeyValuePair<string, int[]> pair in wordsFreqs)
            //{
            //    form.drawGraph(pair.Key, pair.Value);
            //    break;
            //}
        }
示例#4
0
        private void showSentButton_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count != 1)
            {
                goto end2;
            }
            string     curWord = dataGridView1.CurrentCell.Value.ToString();
            Parameters param   = new Parameters();

            param.word = curWord;
            int[] frqMas = new int[11];
            try
            {
                GetSentForSelectedWord sentDistr = new GetSentForSelectedWord(BDLocation, tableName, param);
                frqMas = sentDistr.GetFreqDestribution(sentDistr, sentCount, 11);
                string output = "";
                for (int i = 0; i < 11; i++)
                {
                    output += frqMas[i] + " ";
                }
                TerminSurroundingsForm form2 = new TerminSurroundingsForm(sentDistr.dataSet);
                DataRowCollection      rows  = sentDistr.dataSet.Tables[0].Rows;
                form2.Text       = rows.Count + " предложений из " + sentCount;
                form2.ClientSize = new Size(form2.dataGridView1.Size.Width, form2.ClientSize.Height);
                form2.Show();
                if (dataGridView1.Columns.Count != 0)
                {
                    form2.dataGridView1.Columns[0].Width = 550;
                    form2.dataGridView1.Columns[1].Width = 200;
                }
                MessageBox.Show("Распределение частоты:\n" + output);
            }
            catch (OleDbConnectionException ex)
            {
                MessageBox.Show(ex.message);
            }
            catch (OleDbSendCommandException ex)
            {
                MessageBox.Show(ex.message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            goto goodEnd;
            end2    : MessageBox.Show("Выберите одно слово");
            goodEnd :;
        }
示例#5
0
        private void AllFreqButton_Click(object sender, EventArgs e)
        {
            DataTable allFreq = new DataTable();

            allFreq.Columns.Add(new DataColumn("НормФорма"));
            allFreq.Columns["НормФорма"].DataType = typeof(string);
            int sentStep = sentCount / 10;

            for (int i = 0; i < 10; i++)
            {
                string sentInterval;
                if (i == 10)
                {
                    sentInterval = Convert.ToString(i * sentStep) + "-" + Convert.ToString(sentCount);
                }
                else
                {
                    sentInterval = Convert.ToString(i * sentStep) + "-" + Convert.ToString((i + 1) * sentStep - 1);
                }
                allFreq.Columns.Add(new DataColumn(sentInterval));
                allFreq.Columns[sentInterval].DataType = typeof(string);
            }
            List <int[]> wordsDistrList = new List <int[]>();
            //try
            //{
            DataRowCollection wordRows = ds.Tables[0].Rows;

            for (int j = 0; j < wordRows.Count; j++)
            {
                Parameters param = new Parameters();
                param.word = wordRows[j][0].ToString();
                GetSentForSelectedWord sentFreq = new GetSentForSelectedWord(BDLocation, tableName, param);
                int[] frqMas = sentFreq.GetFreqDestribution(sentFreq, sentCount, 10);
                wordsDistrList.Add(frqMas);
                DataRow row = allFreq.NewRow();
                row["НормФорма"] = param.word;
                for (int i = 0; i < 10; i++)
                {
                    string sentInterval;
                    if (i == 10)
                    {
                        sentInterval = Convert.ToString(i * sentStep) + "-" + Convert.ToString(sentCount);
                    }
                    else
                    {
                        sentInterval = Convert.ToString(i * sentStep) + "-" + Convert.ToString((i + 1) * sentStep - 1);
                    }
                    row[sentInterval] = frqMas[i];
                }
                allFreq.Rows.Add(row);
            }
            DataSet dst = new DataSet();

            dst.Tables.Add(allFreq);
            TerminSurroundingsForm form2 = new TerminSurroundingsForm(dst);

            form2.Text = "Распределения частот";
            form2.Show();
            //}
            //catch (OleDbConnectionException ex)
            //{
            //    MessageBox.Show(ex.message);
            //}
            //catch (OleDbSendCommandException ex)
            //{
            //    MessageBox.Show(ex.message);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.Message);
            //}
        }
示例#6
0
        private void StatisticButton_Click(object sender, EventArgs e)
        {
            DataTable allStat = new DataTable();

            allStat.Columns.Add(new DataColumn("НормФорма"));
            allStat.Columns.Add(new DataColumn("минимФрагмент"));
            allStat.Columns["минимФрагмент"].DataType = typeof(double);
            allStat.Columns.Add(new DataColumn("минНачНомерПредл"));
            allStat.Columns["минНачНомерПредл"].DataType = typeof(double);
            allStat.Columns.Add(new DataColumn("минКонНомерПредл"));
            allStat.Columns["минКонНомерПредл"].DataType = typeof(double);
            allStat.Columns.Add(new DataColumn("максФрагмент"));
            allStat.Columns["максФрагмент"].DataType = typeof(double);
            allStat.Columns.Add(new DataColumn("максНачНомерПредл"));
            allStat.Columns["максНачНомерПредл"].DataType = typeof(double);
            allStat.Columns.Add(new DataColumn("максКонНомерПредл"));
            allStat.Columns["максКонНомерПредл"].DataType = typeof(double);
            allStat.Columns.Add(new DataColumn("макс/мин"));
            allStat.Columns["макс/мин"].DataType = typeof(double);
            try
            {
                DataRowCollection wordRow = ds.Tables[0].Rows;
                int n = Convert.ToInt32(nTextBox.Text);
                for (int j = 0; j < wordRow.Count; j++)
                {
                    Parameters param = new Parameters();
                    param.word = wordRow[j][0].ToString();
                    GetSentForSelectedWord ts       = new GetSentForSelectedWord(BDLocation, tableName, param);
                    DataRowCollection      sentRows = ts.dataSet.Tables[0].Rows;
                    d1Statistic            stat     = new d1Statistic(sentCount);
                    for (int i = 0; i < sentRows.Count - n; i++)
                    {
                        int dist = Convert.ToInt32(sentRows[i + n][1]) - Convert.ToInt32(sentRows[i][1]);
                        if (dist < stat.d1)
                        {
                            stat.d1 = dist;
                            stat.d1SentNumberBegin = Convert.ToInt32(sentRows[i][1]);
                            stat.d1SentNumberEnd   = Convert.ToInt32(sentRows[i + n][1]);
                        }
                        if (dist > stat.D1)
                        {
                            stat.D1 = dist;
                            stat.D1SentNumberBegin = Convert.ToInt32(sentRows[i][1]);
                            stat.D1SentNumberEnd   = Convert.ToInt32(sentRows[i + n][1]);
                        }
                    }
                    DataRow row = allStat.NewRow();
                    row["НормФорма"]     = param.word;
                    row["минимФрагмент"] = Math.Round((double)stat.d1 / sentCount, 6);
                    //      row["минНачНомерПредл"] = Math.Round((double)stat.d1SentNumberBegin / sentCount, 5);
                    row["минНачНомерПредл"] = (double)stat.d1SentNumberBegin;
                    //      row["минКонНомерПредл"] = Math.Round((double)stat.d1SentNumberEnd / sentCount, 5);
                    row["минКонНомерПредл"] = (double)stat.d1SentNumberEnd;
                    row["максФрагмент"]     = Math.Round((double)stat.D1 / sentCount, 6);
                    //      row["максНачНомерПредл"] = Math.Round((double)stat.D1SentNumberBegin / sentCount, 5);
                    row["максНачНомерПредл"] = (double)stat.D1SentNumberBegin;
                    //    row["максКонНомерПредл"] = Math.Round((double)stat.D1SentNumberEnd / sentCount, 5);
                    row["максКонНомерПредл"] = (double)stat.D1SentNumberEnd;
                    if (stat.d1 == 0)
                    {
                        row["макс/мин"] = sentCount;
                    }
                    else
                    {
                        row["макс/мин"] = Math.Round((double)stat.D1 / stat.d1, 5);
                    }
                    allStat.Rows.Add(row);
                }
                allStat.DefaultView.Sort = "макс/мин DESC";
                allStat = allStat.DefaultView.ToTable();
                DataSet dst = new DataSet();
                dst.Tables.Add(allStat);
                FreqDestributionForm form2 = new FreqDestributionForm(dst);
                form2.destributionTable.Columns["минимФрагмент"].DefaultCellStyle.BackColor = Color.LightGray;
                form2.destributionTable.Columns["максФрагмент"].DefaultCellStyle.BackColor  = Color.LightGray;
                form2.destributionTable.Columns["макс/мин"].DefaultCellStyle.BackColor      = Color.LightGray;
                form2.Text = "Статистики";
                form2.Show();
            }
            catch (OleDbConnectionException ex)
            {
                MessageBox.Show(ex.message);
            }
            catch (OleDbSendCommandException ex)
            {
                MessageBox.Show(ex.message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }