Пример #1
0
        private void openFileButton_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (openFileDialog.SafeFileName.EndsWith(".json"))
                {
                    tweetsPath = openFileDialog.FileName;
                    tweetDatas = JsonFileController.ReadDataFromJsonFile <TweetData[]>(tweetsPath);

                    // RegisterUsers() should be called before ParseTweets()
                    // because we check words array is null or not in RegisterUsers().
                    RegisterUsers();
                    ParseTweets();

                    // save parsed tweets to json file.
                    JsonFileController.WriteToJsonFile(tweetsPath, tweetDatas);

                    // Navigate to first tweet.
                    NavigateLabeledData_Click(null, new EventArgs());

                    FillTweetInfo();
                }
                else
                {
                    MessageBox.Show("Please choose a json file.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
0
        private void combineButton_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBD.ShowDialog();

            if (result == DialogResult.OK)
            {
                JsonFileController.CombineAllJsonFiles(folderBD.SelectedPath);
            }
        }
Пример #3
0
 private void btnLoadAnn_Click(object sender, EventArgs e)
 {
     trainer = JsonFileController.ReadDataFromJsonFile <Trainer>(Path.Combine(nnParentPath, TrainDataFile));
     ShowNeuralNetworkInfo(trainer.Neuralnetwork);
     trackbarschanged      = false;
     btnNNTraining.Enabled = btnNNTesting.Enabled = btnTest.Enabled = btnCMatrix.Enabled = true;
     toggle1.Value         = trainer.trainingType == TrainingType.WORD_TRAINING ? true : false;
     trainedType           = trainer.trainingType;
     lblsystemType.Text    = trainingType.ToString();
 }
Пример #4
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (fileChanged)
            {
                DialogResult dialogResult = MessageBox.Show("Would you like to save changed datas to file?", "Data Changed", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                switch (dialogResult)
                {
                case DialogResult.None:
                    break;

                case DialogResult.OK:
                    break;

                case DialogResult.Cancel:
                    e.Cancel = true;
                    break;

                case DialogResult.Abort:
                    break;

                case DialogResult.Retry:
                    break;

                case DialogResult.Ignore:
                    break;

                case DialogResult.Yes:
                    JsonFileController.WriteToJsonFile(tweetsPath, tweetDatas);
                    break;

                case DialogResult.No:
                    break;

                default:
                    break;
                }
            }
            Application.Exit();
        }
Пример #5
0
        private void TrainTest(TrainingType type)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                MessageBox.Show("you have to choose a file to train....");
                return;
            }

            btnTest.Enabled   = true;
            progressBar.Value = 0;

            TweetData[] twData = JsonFileController.ReadDataFromJsonFile <TweetData[]>(filePath);
            ParseTweets(ref twData, type);

            Analyser analyser = new Analyser(twData, labels, tbTestCount.Value, chckPickRandomly.Checked);

            if (type == TrainingType.WORD_TRAINING)
            {
                analyser.Analyse1();
            }
            else
            {
                analyser.Analyse2();
            }

            progressBar.Maximum = twData.Length;

            trainer = new Trainer(analyser, tbHiddenNeuronCount.Value, double.Parse(lblLearningRate.Text), type);

            List <List <Tuple <int, double> > > list;

            if (type == TrainingType.WORD_TRAINING)
            {
                trainer.Train1(progressBar);
                list = trainer.Test1(progressBar);
            }
            else
            {
                trainer.Train2(progressBar);
                list = trainer.Test2(progressBar);
            }

            Test(type, analyser);
            //richtxtAnnResult.Text = "";
            //for (int i = 0; i < analyser.TestingTweets.Length; i++)
            //{
            //    richtxtAnnResult.AppendText("TWEET:\n\n");
            //    richtxtAnnResult.AppendText(analyser.TestingTweets[i].tweet + "\n\n");


            //    richtxtAnnResult.AppendText("PREDICTION:\n\n");
            //    for (int j = 0; j < list[i].Count; j++)
            //    {
            //        string val = labels[list[i][j].Item1];
            //        double percentage = list[i][j].Item2 * 100;
            //        richtxtAnnResult.AppendText(val + ":\t" + percentage.ToString("F2") + "%\n");
            //    }

            //    richtxtAnnResult.AppendText("\nANSWER: " + analyser.TestingTweets[i].users[0].labels[0]);

            //    richtxtAnnResult.AppendText("\n\n");
            //    richtxtAnnResult.AppendText("#################################################################\n\n");
            //}

            ShowAnalyserInfo(trainer);
        }
Пример #6
0
 private void btnSaveANN_Click(object sender, EventArgs e)
 {
     trainer.trainingType = trainedType;
     JsonFileController.WriteToJsonFile(Path.Combine(nnParentPath, TrainDataFile), trainer);
 }
Пример #7
0
 private void WriteToFile_Click(object sender, EventArgs e)
 {
     JsonFileController.WriteToJsonFile(tweetsPath, tweetDatas);
     fileChanged = false;
 }