Exemplo n.º 1
0
        private void analysisTFIDF()
        {
            string content = textBox1.Text;
            var    dfs     = AnalyzeTool.loadDF();
            var    words   = AnalyzeTool.getTFIDF(content, dfs);
            string output  = "";

            foreach (var w in words)
            {
                output += string.Format("{0}-{1}\r\n", w.Word, w.Num);
            }
            printChangeResult(output);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 文档词频预处理,得到一个文件 WordDFs.txt
        /// </summary>
        private void analysisDF()
        {
            string path = AnalyzeTool.dataDic;

            string[] files = Directory.GetFiles(path, "*.txt");
            for (int i = 0; i < files.Length; i++)
            {
                string f   = files[i];
                var    dfs = AnalyzeTool.loadDF();
                dfs = AnalyzeTool.getIDF(dfs, new string[] { f });
                AnalyzeTool.saveDF(dfs);
                print(string.Format("完成:{0}({1}/{2})", f, i + 1, files.Length));

                string tpath = "./backup/";
                if (!Directory.Exists(tpath))
                {
                    Directory.CreateDirectory(tpath);
                }
                File.Move(f, tpath + Path.GetFileName(f));
            }
            print(string.Format("over.({0})", files.Length));
        }