Esempio n. 1
0
        /// <summary>
        /// Given the 2 maps fills a document for 1 word.
        /// </summary>
        private static int Index(System.Collections.IDictionary word2Nums, System.Collections.IDictionary num2Words, System.String g, Document doc)
        {
            var keys = (System.Collections.IList)word2Nums[g];              // get list of key#'s
            var i2   = keys.GetEnumerator();

            var already = new System.Collections.SortedList();             // keep them sorted

            // pass 1: fill up 'already' with all words
            while (i2.MoveNext())             // for each key#
            {
                foreach (var item in
                         ((System.Collections.IList)num2Words[i2.Current]).Cast <object>().Where(item => already.Contains(item) == false))
                {
                    already.Add(item, item);
                }
            }

            var num = 0;

            already.Remove(g);             // of course a word is it's own syn
            var it = already.GetEnumerator();

            while (it.MoveNext())
            {
                var cur = (String)it.Key;
                // don't store things like 'pit bull' -> 'american pit bull'
                if (!IsDecent(cur))
                {
                    continue;
                }
                num++;
                doc.Add(new Field(F_SYN, cur, Field.Store.YES, Field.Index.NO));
            }
            return(num);
        }
Esempio n. 2
0
 /// <summary>
 /// 方法:初始化设备列表中的设备
 /// </summary>
 public void DeviceListInit()
 {
     System.Collections.IDictionaryEnumerator mDicEnumerator = DeviceList.GetEnumerator();
     while (mDicEnumerator.MoveNext())
     {
         Device.IDevice mIDevice = mDicEnumerator.Value as Device.IDevice;//调用实现该接口的类
         try
         {
             mIDevice.Init();
         }
         catch /*(ProCommon.Communal.InitException initex)*/
         {
             //ProCommon.Communal.LogWriter.WriteException(_exLogFilePath, initex);
             //ProCommon.Communal.LogWriter.WriteLog(_sysLogFilePath, string.Format("错误:初始化设备列表失败!\n异常描述:{0}", initex.Message));
         }
     }
 }
Esempio n. 3
0
		/// <summary> 
		/// Given the 2 maps fills a document for 1 word.
		/// </summary>
		private static int Index(System.Collections.IDictionary word2Nums, System.Collections.IDictionary num2Words, System.String g, Document doc)
		{
			var keys = (System.Collections.IList) word2Nums[g]; // get list of key#'s
			var i2 = keys.GetEnumerator();
			
			var already = new System.Collections.SortedList(); // keep them sorted
			
			// pass 1: fill up 'already' with all words
			while (i2.MoveNext()) // for each key#
			{
				foreach (var item in
					((System.Collections.IList) num2Words[i2.Current]).Cast<object>().Where(item => already.Contains(item) == false))
				{
					already.Add(item, item);
				}
			}

			var num = 0;
			already.Remove(g); // of course a word is it's own syn
			var it = already.GetEnumerator();
			while (it.MoveNext())
			{
				var cur = (String) it.Key;
				// don't store things like 'pit bull' -> 'american pit bull'
				if (!IsDecent(cur))
				{
					continue;
				}
				num++;
				doc.Add(new Field(F_SYN, cur, Field.Store.YES, Field.Index.NO));
			}
			return num;
		}
Esempio n. 4
0
 public System.Collections.IEnumerator GetEnumerator()
 {
     return(_list.GetEnumerator());
 }
		/// <summary>
		/// Create an ASCII Ramp with from the given font and characters
		/// </summary>
		/// <param name="font">Font to be used</param>
		/// <param name="characters">The characters to be used for the ramp</param>
		/// <returns>A new ASCII ramp</returns>
		public static string CreateRamp(Font font, string characters)
		{
			if (characters == null || characters.Length < 1)
				return null;

			if (characters.Length == 1)
				return characters;

			string characterstring = "";

			foreach (char c in characters.ToCharArray())
			{
				if (characterstring.IndexOf(c) == -1)
				{
					characterstring += c.ToString();
				}
			}

			System.Collections.SortedList list = new System.Collections.SortedList();

			int min = 255;
			int max = 0;

			CharacterValue charval;

			for (int i = 0; i < characterstring.Length; i++)
			{
				charval = new CharacterValue(characterstring[i], font);

				if (list.ContainsKey(charval.Value))
				{
					if (charval.Score < ((CharacterValue)list[charval.Value]).Score)
					{
						list[charval.Value] = charval;
					}
				}
				else
				{
					if (charval.Value < min)
						min = charval.Value;

					if (charval.Value > max)
						max = charval.Value;

					list.Add(charval.Value, charval);
				}
			}

			list.TrimToSize();


			string result = "";

			System.Collections.IDictionaryEnumerator idenu = list.GetEnumerator();

			// move to the first object
			idenu.MoveNext();

			int current = (int)idenu.Key;
			int next, mid;

			// loop through and fill in the gaps
			while (idenu.MoveNext())
			{
				next = (int)idenu.Key;
				mid = ((next - current) / 2) + current;

				for (int i = current; i < mid; i++)
				{
					result += list[current];
				}

				for (int i = mid; i < next; i++)
				{
					result += list[next];
				}

				current = next;
			}

			return result;
		}
        /// <summary>
        /// Create an ASCII Ramp with from the given font and characters
        /// </summary>
        /// <param name="font">Font to be used</param>
        /// <param name="characters">The characters to be used for the ramp</param>
        /// <returns>A new ASCII ramp</returns>
        public static string CreateRamp(Font font, string characters)
        {
            if (characters == null || characters.Length < 1)
            {
                return(null);
            }

            if (characters.Length == 1)
            {
                return(characters);
            }

            string characterstring = "";

            foreach (char c in characters.ToCharArray())
            {
                if (characterstring.IndexOf(c) == -1)
                {
                    characterstring += c.ToString();
                }
            }

            System.Collections.SortedList list = new System.Collections.SortedList();

            int min = 255;
            int max = 0;

            CharacterValue charval;

            for (int i = 0; i < characterstring.Length; i++)
            {
                charval = new CharacterValue(characterstring[i], font);

                if (list.ContainsKey(charval.Value))
                {
                    if (charval.Score < ((CharacterValue)list[charval.Value]).Score)
                    {
                        list[charval.Value] = charval;
                    }
                }
                else
                {
                    if (charval.Value < min)
                    {
                        min = charval.Value;
                    }

                    if (charval.Value > max)
                    {
                        max = charval.Value;
                    }

                    list.Add(charval.Value, charval);
                }
            }

            list.TrimToSize();


            string result = "";

            System.Collections.IDictionaryEnumerator idenu = list.GetEnumerator();

            // move to the first object
            idenu.MoveNext();

            int current = (int)idenu.Key;
            int next, mid;

            // loop through and fill in the gaps
            while (idenu.MoveNext())
            {
                next = (int)idenu.Key;
                mid  = ((next - current) / 2) + current;

                for (int i = current; i < mid; i++)
                {
                    result += list[current];
                }

                for (int i = mid; i < next; i++)
                {
                    result += list[next];
                }

                current = next;
            }

            return(result);
        }