示例#1
0
        public Hoot(string IndexPath, string FileName, bool DocMode)
        {
            _Path     = IndexPath;
            _FileName = FileName;
            _docMode  = DocMode;
            if (_Path.EndsWith(Path.DirectorySeparatorChar.ToString()) == false)
            {
                _Path += Path.DirectorySeparatorChar;
            }
            Directory.CreateDirectory(IndexPath);

            _log.Debug("Starting hOOt....");
            _log.Debug("Storage Folder = " + _Path);

            if (DocMode)
            {
                _docs = new KeyStoreString(_Path + "files.docs", false);
                // read deleted
                _deleted    = new BoolIndex(_Path, "_deleted", ".hoot");
                _lastDocNum = (int)_docs.Count();
            }
            _bitmaps = new BitmapIndex(_Path, _FileName + "_hoot.bmp");
            // read words
            LoadWords();
        }
示例#2
0
        /// <summary>
        /// Construct a new object using configuration file and custom tokenizer
        /// </summary>
        /// <param name="config">Configuration file</param>
        /// <param name="tokenizer">Custom Tokenizer to parse text </param>
        public Hoot(IHootConfig config, ITokenizer tokenizer)
        {
            HootConfOptions = config;

            _tokenizer = (tokenizer != null) ? tokenizer : new tokenizer();

            if (!Directory.Exists(config.IndexPath))
            {
                Directory.CreateDirectory(config.IndexPath);
            }

            _log.Debug("Starting hOOt....");
            _log.Debug($"Storage Folder = {config.IndexPath}");

            _tokenizer.InitializeStopList(config.IndexPath);

            _log.Debug($"Stop List Words saved to {config.IndexPath}");

            if (config.DocMode)
            {
                _docs = new KeyStoreString(Path.Combine(config.IndexPath, $"files.docs"), false);
                //
                // read deleted
                //
                _deleted    = new BoolIndex(Path.Combine(config.IndexPath, $"_deleted.hoot"));
                _lastDocNum = (int)_docs.Count();
            }
            _bitmaps = new BitmapIndex(Path.Combine(config.IndexPath, $"{config.FileName}_hoot.bmp"));
            //
            // read words
            //
            LoadWords();
        }