private void buttonTfIdf_Click(object sender, EventArgs e) { // check format if (!isOneWord()) { MessageBox.Show("Неверный формат входной строки.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // get first form of source string string sourceString = sourceFirstForm(); // get other data int collectionLength = 0; int usedCount = 0; using (var db = new Connector.Redmine.Model.dbEntities()) { collectionLength = db.Words.Where(i => i.WordsInText == 1).Sum(i => i.Count); usedCount = db.Words.Where(i => i.Text == sourceString).Sum(i => i.Count); } // get result var tfIdf = new TA.Statistic.TfIdf(_words); var result = tfIdf.Calculate(sourceString, collectionLength, usedCount); // print result Logger.LogText(string.Format("Метод TF*IDF [{0}]: {1}.", sourceString, result)); Logger.LogHtml(string.Format("<p><strong>Метод TF*IDF [{0}]:</strong> {1}.</p>", sourceString, result)); }