不知道为什么,我的lucene.net一加入中文分词就报错:提示:值必须为正 参数名:count  好像是在读取的时候,谁能帮帮我啊?我的QQ是:303536503,摆脱大家了,分不是很多,等以后再加!

解决方案 »

  1.   

    贴出代码看看,哪里出错
    检查count  值
      

  2.   

    //建立索引
            public void CreateIndex()
            {
                //Analyzer analyzer = new StandardAnalyzer();
                //Analyzer analyzer = new IKAnalyzer();            Analyzer analyzer = new Lucene.China.ChineseAnalyzer();
                //Analyzer analyzer = new PanGuAnalyzer();
                
                IndexWriter writer = new IndexWriter("c:\\Inetpub\\wwwroot\\index", analyzer, true);
                XmlDocument doc = new XmlDocument();
                doc.Load("c:\\Inetpub\\wwwroot\\test.xml");
                XmlNodeList nodeList;
                XmlNode root = doc.DocumentElement;
                nodeList = root.SelectNodes("//resourceitem");
                foreach (XmlNode resitem in nodeList)
                {
                    
                    AddDocument(writer, resitem.ChildNodes[1].InnerText, resitem.ChildNodes[2].InnerText, resitem.ChildNodes[3].InnerText, resitem.ChildNodes[4].InnerText, resitem.ChildNodes[5].InnerText, resitem.ChildNodes[6].InnerText, resitem.ChildNodes[7].InnerText, resitem.ChildNodes[8].InnerText, 0.1f);            }            writer.Optimize();
                writer.Close();
            }
    //加入文档
            static void AddDocument(IndexWriter writer, string title, string keywords, string kind, string describe, string date, string url, string author, string publisher, float boost)
            {
                Document document = new Document();
                document.Add(new Field("title", title, Field.Store.YES, Field.Index.TOKENIZED));
                document.Add(new Field("keywords", keywords, Field.Store.YES, Field.Index.TOKENIZED));
                document.Add(new Field("kind", kind, Field.Store.YES, Field.Index.TOKENIZED));
                document.Add(new Field("describe", describe, Field.Store.YES, Field.Index.TOKENIZED));
                document.Add(new Field("date", date, Field.Store.YES, Field.Index.TOKENIZED));
                document.Add(new Field("url", url, Field.Store.YES, Field.Index.TOKENIZED));
                document.Add(new Field("author", author, Field.Store.YES, Field.Index.TOKENIZED));
                document.Add(new Field("publisher", publisher, Field.Store.YES, Field.Index.TOKENIZED));
                document.SetBoost(boost);
                writer.AddDocument(document);        }添加文档时候报错
      

  3.   

    /// <summary>Constructs a tokenizer for this Reader. </summary>
    public ChineseTokenizer(System.IO.TextReader reader)
    {
    this.input = reader;
                text = input.ReadToEnd();            dataLen = text.Length;
            }红色字体,报错的地方
      

  4.   

    static void ReadText(TextReader textReader)
    {
        Console.WriteLine("{0}",textReader.ReadToEnd());
    }
    是没问题的
    ChineseTokenizer在那里调用的
      

  5.   

    竟然都是Store.YES,Index.TOKENIZED