Program.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:5k
源码类别:

搜索引擎

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading;
  5. /*
  6.       '       迅龙中文分类搜索引擎  v0.6
  7.       '
  8.       '        LGPL  许可发行
  9.       '
  10.       '       宁夏大学  张冬 康彩  zd4004@163.com
  11.       ' 
  12.       '        官网 http://blog.163.com/zd4004/
  13.  */
  14. namespace XunLong.IndexBuilder
  15. {
  16.     class Program
  17.     {
  18.         static void Main(string[] args)
  19.         {
  20.             Console.WriteLine("  >------------------------------------------<");
  21.             Console.WriteLine("  >------------------------------------------<");
  22.             Console.WriteLine("  >          列表中文搜索引擎_组件v0.3       <");
  23.             Console.WriteLine("  >                  索引器                  <");
  24.             Console.WriteLine("  >------------------------------------------<");
  25.             Console.WriteLine("  >------------------------------------------<");
  26.             string k_c_path = args[0];
  27.             Console.WriteLine("--》加载配置文件: " + k_c_path);
  28.             XunLong.CongifData.Config.InitConfigData(k_c_path);
  29.             // D:XunLongXunLong.TestDataXunLongIndex D:XunLongXunLong.ConsoleSpiderOnebinDebugWEB D:XunLongXunLong.TestDataCnStopWord.XL
  30.             
  31.             /*
  32.             if(args.Length<2)
  33.             {
  34.                 Console.WriteLine("参数错误  ");
  35.                 Console.WriteLine("  程序 索引存放地址 文件系统地址 停止词存放地址 模板存放地址 分词缓存地址 ");
  36.                 
  37.                 Console.WriteLine("任意键退出  ");
  38.                 int i = Console.Read();
  39.                 return;
  40.             }
  41.             string a = args[0].Trim(); //索引文件路径
  42.             string b = args[1].Trim(); // 数据路径 
  43.             string c = args[2].Trim(); // 停止词路径
  44.             string d = args[3].Trim(); // 模板存放地址
  45.             string e = args[4].Trim(); // 分词缓存存放地址
  46.             */
  47.             string a = XunLong.CongifData.Config.IndexData; //索引文件路径
  48.             string b = XunLong.CongifData.Config.SpiderData; // 数据路径 
  49.             string c = XunLong.CongifData.Config.StopWordData; // 停止词路径
  50.             string d = XunLong.CongifData.Config.ModelData; // 模板存放地址
  51.             string e = XunLong.CongifData.Config.xWordCacheData; // 分词缓存存放地址
  52.             if ((System.IO.Directory.Exists(a) == false) | (System.IO.Directory.Exists(b) == false) | (System.IO.File.Exists(c) == false) | (System.IO.Directory.Exists(d) == false) | (System.IO.File.Exists(e) == false))
  53.             {
  54.                 Console.WriteLine("参数配置错误  指定的目录不存在! ");
  55.                 Console.WriteLine("任意键退出  ");
  56.                 int i = Console.Read();
  57.                 return;
  58.             }
  59.             Console.WriteLine("索引生成器开始工作  ");
  60.             Console.WriteLine("  LGPL 发行  ");
  61.             Console.WriteLine(" 宁夏大学 张冬 康彩 zd4004@163.com    2006.8.17  ");
  62.             Console.WriteLine(" ");
  63.             ClassIndexBuilder m = new ClassIndexBuilder();
  64.             m.IndexPath =a;
  65.             m.SourcePath = b;
  66.             m.StopPath = c;
  67.             m.ModelPath = d;
  68.             m.OKxWordPath = e;
  69.             Console.WriteLine("索引文件路径: " + a);
  70.             Console.WriteLine("文件系统路径: " + b);
  71.             Console.WriteLine("停止词路径 : " + c);
  72.             Console.WriteLine("模板存放路径: " + d);
  73.             Console.WriteLine("分词缓存路径: " + e);
  74.             m.initNFS(k_c_path);
  75.             Console.WriteLine( "数据初始化  完成");
  76.            
  77.             Thread T0 = new Thread(new ThreadStart(m.Run));
  78.             T0.Start();
  79.              Console.WriteLine( "输入x 退出索引  ");
  80.             while (true)
  81.             {
  82.                System.ConsoleKeyInfo  dd =Console.ReadKey() ;
  83.                Console.WriteLine("开始退出索引  ");
  84.                 string  df =dd.Key.ToString();
  85.                 if (df == "X" | df == "x" | df == "120")
  86.                 {
  87.                     m.StopIt = true;
  88.                     Thread.Sleep(3000);
  89.                     Console.WriteLine("退出索引..  ");
  90.                     Thread.Sleep(3000);
  91.                     while (true)
  92.                     {
  93.                         if (m.isEndOK == true)
  94.                         {
  95.                             Console.WriteLine("退出索引....  ");
  96.                             
  97.                             T0.Abort();
  98.                             return;
  99.                         }
  100.                         Thread.Sleep(2000);
  101.                     }
  102.                 }
  103.             }
  104.         }
  105.     }
  106. }