当前位置:编程学习 > C#/ASP.NET >>

请高手修改代码


       static string data = "";
       static path ;
       static void Main(string[] args)
        {
          string[] allfiles = Directory.GetFiles()
          for(int i = 0; i < allfiles.length; i++)
          {
            path = allfiles[i]
            StreamReader TxtReader = new StreamReader(path, Encoding.Default);
            string FileContent;
            FileContent = TxtReader.ReadToEnd();
            TxtReader.Close();
             .......
            string str ="字串。。。。。";
            string[] arr = str.Split(new char[]{' '});
            foreach(string s in arr)
            {
                data = s.Trim();

                if(htable.ContainsKey(s))
                {  
                    num = (int)htable[s];
                    num = num + 1;
                    htable[s] = num;
                }
                else
                    htable.Add(s, 1);
            }

            foreach (DictionaryEntry de in htable)
            {
                string phrase = (string)de.Key;   
                num = (int)de.Value;         

                data = data + "\t" + num;
                
                Console.WriteLine(data);
            }
          }
            Console.ReadLine();
        }
这段代码把一个文件下的所有文本处理成词,并计算了每个词的频次,想要把每个词在几个文件中出现,应该怎样修改,或是需要添加哪些东西。。。 --------------------编程问答-------------------- http://topic.csdn.net/u/20110507/21/a797e59f-9089-4349-b474-f2c878b57d7e.html

参考我的程序,给 tire tree 增加一个计数节点。 --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答--------------------
引用 1 楼 caozhy 的回复:
http://topic.csdn.net/u/20110507/21/a797e59f-9089-4349-b474-f2c878b57d7e.html

参考我的程序,给 tire tree 增加一个计数节点。

算法很强大,先学习了

我要的处理的是中文文本,不需要考虑分词,只计算每个词条在几个文本文件中出现。 --------------------编程问答-------------------- htable 是什么 --------------------编程问答--------------------
引用 5 楼 sugarbelle 的回复:
htable 是什么

Hashtable htable = new Hashtable(); --------------------编程问答-------------------- 沉了。。。 --------------------编程问答--------------------   看的真费劲
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,