using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Njust.Pdf.Analysis
{
    public class CnStopWordsHandler
    {
        public static string[] CnstopWordsList = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Resources\\Cnstopwords.txt"));

        private static readonly Hashtable _stopwords = null;

        public static object AddElement(IDictionary collection, Object key, object newValue)
        {
            object element = collection[key];
            collection[key] = newValue;
            return element;
        }

        public static bool IsStopword(string str)
        {

            //int index=Array.BinarySearch(stopWordsList, str)
            return _stopwords.ContainsKey(str.ToLower());
        }


        static CnStopWordsHandler()
        {
            if (_stopwords == null)
            {
                _stopwords = new Hashtable();
                double dummy = 0;
                foreach (string word in CnstopWordsList)
                {
                    AddElement(_stopwords, word, dummy);
                }
            }
        }

    }
}
