Пример #1
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();
        }