
using System;
using System.Collections;
using System.IO;

namespace Njust.Pdf.Analysis
{

    /// <summary>
    /// ÓÃÓÚÒÆ³ýÓ¢ÎÄÍ£Ö¹´Ê
    /// </summary>
	public class StopWordsHandler
	{		
		public static string[] EnstopWordsList= File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Resources\\stopwords.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 StopWordsHandler()
		{
			if (_stopwords == null)
			{
				_stopwords = new Hashtable();
				double dummy = 0;
				foreach (string word in EnstopWordsList)
				{
					AddElement(_stopwords, word, dummy);
				}
			}
		}

	}
}

