private async void button5_Click_1(object sender, EventArgs e) { openFileDialog1.Filter = "Текстовые файлы (*.txt)|*.txt|Все файлы (*.*)|*.*"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string[] rows = File.ReadAllLines(openFileDialog1.FileName); int countRows = rows.Length; string[] domains = new string[countRows]; string[] labelsClass = new string[countRows]; for (int i = 0; i < countRows; i++) { string[] row = rows[i].Split('\t'); domains[i] = row[0]; labelsClass[i] = row[1]; } Ngram ngram = Ngram.getInstance(); progressBar1.Maximum = countRows; await Task.Factory.StartNew(() => { for (int i = 2; i < 6; i++) { ngram.CreateDictionary(domains, labelsClass, i, labelStatus, progressBar1); } }); } }
public static Ngram getInstance() { if (instance == null) { instance = new Ngram(); } return(instance); }