private void загрузитьРезультатыОбученияToolStripMenuItem_Click(object sender, EventArgs e) { try { if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } cp = new CmpParams(); cp.Load(openFileDialog1.FileName); } catch { MessageBox.Show("Ошибка загрузки"); } }
private void начатьОбучениеToolStripMenuItem_Click(object sender, EventArgs e) { try { TeachForm tf = new TeachForm(); if (tf.ShowDialog() != DialogResult.OK) { return; } string[] arrFile = tf.openFileDialog1.FileNames; SortedDictionary <string, double> sdW = new SortedDictionary <string, double>(); for (int i = 0; i < tf.dataGridView1.Rows.Count; i++) { sdW.Add(tf.dataGridView1[0, i].Value.ToString(), double.Parse(tf.dataGridView1[1, i].Value.ToString())); } string regRep = ""; TInput.C_EAnswer[] arrAns = new TInput.C_EAnswer[arrFile.Length]; double[] arrTutMark = new double[arrFile.Length]; double[] arrIMark = new double[arrFile.Length]; double[] arrIW2Mark = new double[arrFile.Length]; double[] arrCos = new double[arrFile.Length]; double[][] mI = new double[Compare.lPosFiltered.Count + 1][]; // матрица инф. по ч.р. и ответам for (int i = 0; i < mI.Length; i++) { mI[i] = new double[arrFile.Length]; } int tut = int.Parse(tf.textBox1.Text) - 1; for (int i = 0; i < arrFile.Length; i++) { arrAns[i] = new TInput.C_EAnswer(arrFile[i]); arrTutMark[i] = arrAns[i].GetTutor(tut).Mark; } for (int i = 0; i < arrAns.Length; i++) { List <Word> lwx = Compare.Parse(arrAns[i].p_etalon_answer), lwy = Compare.Parse(arrAns[i].p_student_answer); string s, syn; SortedDictionary <Word, double>[] arrSDx = Compare.POSFilter(lwx), arrSDy = Compare.POSFilter(lwy); if (Properties.Settings.Default.Syn) { Compare.Syn(arrSDx, arrSDy, out syn); } if (tf.checkBox1.Checked || tf.checkBox2.Checked || tf.checkBox3.Checked) { double[] arrI; double hx, hy, hxy; arrIMark[i] = Compare.KuznetsovCompare(arrSDx, arrSDy, out hx, out hy, out hxy, out arrI, out s); double iw = 0; for (int j = 0; j < arrI.Length; j++) { mI[j][i] = arrI[j]; double w; if (j < Compare.lPosFiltered.Count) { if (sdW.TryGetValue(Compare.lPosFiltered[j], out w)) { iw += arrI[j] * w; } } else if (sdW.TryGetValue("Неопределенная_часть_речи", out w)) // неопределенная часть речи соответствует null { iw += arrI[j] * w; } } arrIW2Mark[i] = iw; } if (tf.checkBox4.Checked) { arrCos[i] = Compare.CosCompare(arrSDx, arrSDy, out s); } } Sample sY = new Sample("Q", "Q", arrTutMark); Regression[] arrReg = new Regression[4]; if (tf.checkBox1.Checked) { arrReg[0] = new Regression(sY, new Sample[] { new Sample("I", "I", arrIMark) }); } if (tf.checkBox2.Checked) { List <Sample> lsX = new List <Sample>(); for (int i = 0; i < Compare.lPosFiltered.Count + 1; i++) { int j; for (j = 0; j < mI[i].Length; j++) { if (mI[i][j] != 0) { break; } } if (j == mI[i].Length) { continue; } if (i < Compare.lPosFiltered.Count) { lsX.Add(new Sample(Compare.lPosFiltered[i], Compare.lPosFiltered[i], mI[i])); } else { lsX.Add(new Sample("Неопределенная_часть_речи", "Неопределенная_часть_речи", mI[i])); } } arrReg[1] = new Regression(sY, lsX.ToArray()); } if (tf.checkBox3.Checked) { arrReg[2] = new Regression(sY, new Sample[] { new Sample("IW2", "IW2", arrIW2Mark) }); } if (tf.checkBox4.Checked) { arrReg[3] = new Regression(sY, new Sample[] { new Sample("cos", "cos", arrCos) }); } string tbl = "<table border=1 cellspacing=0><tr><td>№<td>Оценка преподавателя<td>Число слов в эталоне" + "<td>Число слов в ответе"; if (tf.checkBox1.Checked) { tbl += "<td>Количество информации по ВСММ<td>Тарированная оценка по ВСММ"; } if (tf.checkBox2.Checked) { tbl += "<td>Тарированная оценка по ВСММ с опт. весами"; } if (tf.checkBox3.Checked) { tbl += "<td>Количество информации по ВСММ с зад. весами<td>Тарированная оценка по ВСММ с зад. весами"; } if (tf.checkBox4.Checked) { tbl += "<td>Критерий косинуса угла<td>Тарированная оценка критерия косинуса"; } for (int i = 0; i < arrTutMark.Length; i++) { tbl += string.Format("<tr><td>{0}<td>{1:g3}<td>{2}<td>{3}", i + 1, arrTutMark[i], Compare.Parse(arrAns[i].p_etalon_answer).Count, Compare.Parse(arrAns[i].p_student_answer).Count); if (tf.checkBox1.Checked) { tbl += string.Format("<td>{0:g6}<td>{1:g4}", arrIMark[i], arrReg[0].arrYMod[i]); } if (tf.checkBox2.Checked) { tbl += string.Format("<td>{0:g4}", arrReg[1].arrYMod[i]); } if (tf.checkBox3.Checked) { tbl += string.Format("<td>{0:g6}<td>{1:g4}", arrIW2Mark[i], arrReg[2].arrYMod[i]); } if (tf.checkBox4.Checked) { tbl += string.Format("<td>{0:g6}<td>{1:g4}", arrCos[i], arrReg[3].arrYMod[i]); } } tbl += "</table>"; regRep = "<table border=1 cellspacing=0><tr><td>Метод<td>Регрессия"; if (tf.checkBox1.Checked) { regRep += string.Format("<tr><td>{0}<td>{1}", "Критерий совместной информации по ВСММ", arrReg[0].RegReport()); } if (tf.checkBox2.Checked) { regRep += string.Format("<tr><td>{0}<td>{1}", "Критерий совместной информации по ВСММ с опт. весами", arrReg[1].RegReport()); } if (tf.checkBox3.Checked) { regRep += string.Format("<tr><td>{0}<td>{1}", "Критерий совместной информации по ВСММ с зад. весами", arrReg[2].RegReport()); } if (tf.checkBox4.Checked) { regRep += string.Format("<tr><td>{0}<td>{1}", "Критерий косинуса", arrReg[3].RegReport()); } regRep += "</table>"; regRep = "<br><big>Результаты</big>" + tbl + "<big><br><br>Сравнение методов</big>" + regRep; SortedDictionary <string, double> sdWOpt = null; if (tf.checkBox2.Checked) { sdWOpt = new SortedDictionary <string, double>(); for (int i = 0; i < arrReg[1].arrSX.Length; i++) { sdWOpt.Add(arrReg[1].arrSX[i].name, arrReg[1].arrB[1 + i]); } } cp = new CmpParams() { useI = tf.checkBox1.Checked, useIWOpt = tf.checkBox2.Checked, useIW = tf.checkBox3.Checked, useCos = tf.checkBox4.Checked, sdW = sdW, sdWOpt = sdWOpt, regI = arrReg[0], regIWOpt = arrReg[1], regIW = arrReg[2], regCos = arrReg[3] }; RepForm rf = new RepForm(regRep); rf.Text = "Результаты обучения"; rf.ShowDialog(); } catch { MessageBox.Show("Ошибка обучения"); } }