Пример #1
0
        static void Main(string[] args)
        {
            string[] fileStrings = Directory.GetFiles(testFileDir);  //获取文本文件


            //计算文本文件总大小
            foreach (string fi in fileStrings)
            {
                FileInfo fInfo = new FileInfo(fi);
                totalFileSizeInByte += fInfo.Length;
            }
            for (int i = 0; i < fileStrings.Length; ++i)
            {
                fileList.Add(fileStrings[i]);
            }

            //两线程使用SharpIctClas时行分词
            thread0 = new Thread(new ParameterizedThreadStart(AnalyFuc));
            thread1 = new Thread(new ParameterizedThreadStart(AnalyFuc));
            Para p0 = new Para();
            Para p1 = new Para();

            p0.Num = 0;
            p1.Num = 1;

            Stopwatch threadSp = new Stopwatch();

            threadSp.Start();
            thread0.Start(p0);
            thread1.Start(p1);

            thread0.Join();
            thread1.Join();

            threadSp.Stop();

            Console.WriteLine("SharpICTCLAS" + ":" + threadSp.ElapsedMilliseconds + "ms" + " Word Segmentation Speed: " + (float)totalFileSizeInByte / 1024 / threadSp.ElapsedMilliseconds * 1000 + " KB/s");

            Thread.Sleep(1000);

            //单线程使用C++版ICTCLAS分词
            CPPictclas();
        }
Пример #2
0
        static void Main(string[] args)
        {
            string[] fileStrings = Directory.GetFiles(testFileDir);  //获取文本文件

            
            //计算文本文件总大小
            foreach (string fi in fileStrings)
            {
                FileInfo fInfo = new FileInfo(fi);
                totalFileSizeInByte += fInfo.Length;
            }
            for (int i = 0; i < fileStrings.Length; ++i)
                fileList.Add(fileStrings[i]);

            //两线程使用SharpIctClas时行分词
            thread0 = new Thread(new ParameterizedThreadStart(AnalyFuc));
            thread1 = new Thread(new ParameterizedThreadStart(AnalyFuc));
            Para p0 = new Para();
            Para p1 = new Para();

            p0.Num = 0;
            p1.Num = 1;

            Stopwatch threadSp = new Stopwatch();
            threadSp.Start();
            thread0.Start(p0);
            thread1.Start(p1);

            thread0.Join();
            thread1.Join();

           threadSp.Stop();

           Console.WriteLine("SharpICTCLAS" + ":" + threadSp.ElapsedMilliseconds + "ms"+ " Word Segmentation Speed: "+(float)totalFileSizeInByte/1024/threadSp.ElapsedMilliseconds*1000+" KB/s");

           Thread.Sleep(1000);

            //单线程使用C++版ICTCLAS分词
           CPPictclas();     
    
        }