Ejemplo n.º 1
0
        private void RunPath()
        {
            SubstrStatic subStat = new SubstrStatic();
            string       str     = @"系统工具开始统计....";

            str += "\n\n" + @"系统所用匹配方法为:" + subStat.MatchingClassName;
            str += "\n\n" + @"系统所用排序方法为:" + subStat.SortClassName;
            SetText(str);
            HiperfTimer ht = new HiperfTimer();

            ht.Start();
            string path = txtPath.Text.Trim();
            string dirc = txtdirc.Text.Trim();

            str += "\n\n" + @"系统工具正在读取文件夹中的文件...";
            SetText(str);
            subStat.SourceFromPath(path);
            str += "\n\n" + @"系统工具正在统计词频...";
            SetText(str);
            subStat.SubStringFromFile(dirc);
            List <Node> lst = subStat.Run();

            str += "\n\n" + @"系统工具正在写入文件...";
            SetText(str);
            subStat.Write(lst);
            ht.Stop();
            string cost = Math.Round(ht.Duration_second, 4).ToString(CultureInfo.InvariantCulture);

            str += "\n\n" + @"系统工具所用时间为:" + cost + "秒";
            SetText(str);
        }
Ejemplo n.º 2
0
        private void btnstatic_Click(object sender, EventArgs e)
        {
            string file = txtFile.Text.Trim();
            string path = txtPath.Text.Trim();
            string dirc = txtdirc.Text.Trim();

            lblInfor.Text = string.Empty;

            if (string.IsNullOrEmpty(dirc) == true)
            {
                MessageBox.Show(@"未选择待字典文件.", @"系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SubstrStatic subStat = new SubstrStatic();

            if (rdoSigle.Checked == true) //单个文件统计
            {
                if (string.IsNullOrEmpty(file) == true)
                {
                    MessageBox.Show(@"未选择待分析文件.", @"系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                subStat.SourceFromFile(file);
                subStat.SubStringFromFile(dirc);
                List <Node> lst = subStat.Run();
                subStat.Write(lst);
            }
            else //多个文件统计
            {
                if (string.IsNullOrEmpty(path) == true)
                {
                    MessageBox.Show(@"未选择待分析路径.", @"系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Thread thread = new Thread(RunPath);
                thread.IsBackground = true;
                thread.Start();
            }
        }