Пример #1
0
 /******************************************************************
 ** buttonAdd_Click
 **
 *******************************************************************/
 private void buttonAdd_Click(object sender, System.EventArgs e)
 {
     listBoxSent.Items.Add(textBoxSent.Lines[0]);
     CMarkovSentences.GetInstance().AddString(textBoxSent.Lines[0]);
     textBoxSent.Clear();
     textBoxSent.Focus();
 }
Пример #2
0
        private void comboBoxProb_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            float[,] prob_table;
            string[] prob_table_key;
            int      i, j;

            prob_table     = CMarkovSentences.GetInstance().GetProbMatrix((int)comboBoxProb.SelectedIndex);
            prob_table_key = CMarkovSentences.GetInstance().GetProbMatrixKey();

            listViewProb.Clear();

            listViewProb.Columns.Add("starting ltr", 70, HorizontalAlignment.Center);
            for (i = 0; i < prob_table_key.GetLength(0); i++)
            {
                listViewProb.Columns.Add(prob_table_key[i], 50, HorizontalAlignment.Center);
            }

            for (i = 0; i < prob_table_key.GetLength(0); i++)
            {
                ListViewItem lvi = new ListViewItem(prob_table_key[i]);

                for (j = 0; j < prob_table_key.GetLength(0); j++)
                {
                    lvi.SubItems.Add(prob_table[i, j].ToString("0.###"));
                }
                listViewProb.Items.Add(lvi);
            }
        }
Пример #3
0
 /******************************************************************
 ** GetInstance
 **
 ** The singleton method
 **
 *******************************************************************/
 public static CMarkovSentences GetInstance()
 {
     lock (m_instance_lock)
     {
         if (m_single_instance == null)
         {
             m_single_instance = new CMarkovSentences();
         }
         return(m_single_instance);
     }
 }
Пример #4
0
        /******************************************************************
        ** buttonRemove_Click
        **
        *******************************************************************/
        private void buttonRemove_Click(object sender, System.EventArgs e)
        {
            int row_number;

            /*
            ** Find the row and delete it if there is a row
            */
            row_number = listBoxSent.SelectedIndex;
            if (row_number != -1)
            {
                CMarkovSentences.GetInstance().RemoveString(listBoxSent.Items[row_number].ToString());
                listBoxSent.Items.RemoveAt(row_number);
            }
        }
Пример #5
0
        /******************************************************************
        ** buttonGenerate_Click
        **
        *******************************************************************/
        private void buttonGenerate_Click(object sender, System.EventArgs e)
        {
            string return_string = CMarkovSentences.GetInstance().GenerateString();

            labelSent.Text = return_string;
        }