Esempio n. 1
0
 private static IEnumerable FindClosestAndNextClosestAndPrefixedPairStringLexEntryForms(
     string text, IEnumerable items, IDisplayStringAdaptor adaptor)
 {
     return(ApproximateMatcher.FindClosestForms <object>(items,
                                                         adaptor.GetDisplayLabel,
                                                         text,
                                                         ApproximateMatcherOptions.
                                                         IncludePrefixedAndNextClosestForms));
 }
Esempio n. 2
0
 private static IEnumerable FindClosestAndNextClosestAndPrefixedForms(string text,
                                                                      IEnumerable items,
                                                                      IDisplayStringAdaptor
                                                                      adaptor)
 {
     return(ApproximateMatcher.FindClosestForms(items,
                                                text,
                                                ApproximateMatcherOptions.IncludePrefixedAndNextClosestForms));
 }
Esempio n. 3
0
        private static IEnumerable FilterList(string text,
                                              IEnumerable items,
                                              IDisplayStringAdaptor adaptor)
        {
            ICollection <object> newList = new Collection <object>();

            foreach (object item in items)
            {
                string label = adaptor.GetDisplayLabel(item);
                if (label.ToLower().StartsWith(text.ToLower()))
                {
                    newList.Add(item);
                    break;
                }
            }
            return(newList);
        }
Esempio n. 4
0
		private static IEnumerable FindClosestAndNextClosestAndPrefixedForms(string text,
																			 IEnumerable items,
																			 IDisplayStringAdaptor
																					 adaptor)
		{
			return ApproximateMatcher.FindClosestForms(items,
													   text,
													   ApproximateMatcherOptions.IncludePrefixedAndNextClosestForms);
		}
Esempio n. 5
0
		private static IEnumerable FilterList(string text,
											  IEnumerable items,
											  IDisplayStringAdaptor adaptor)
		{
			ICollection<object> newList = new Collection<object>();

			foreach (object item in items)
			{
				string label = adaptor.GetDisplayLabel(item);
				if (label.ToLower().StartsWith(text.ToLower()))
				{
					newList.Add(item);
					break;
				}
			}
			return newList;
		}
Esempio n. 6
0
 public OptionDisplayAdaptor(OptionsList allOptions, string preferredWritingSystemId)
 {
     _allOptions = allOptions;
     _preferredWritingSystemId = preferredWritingSystemId;
     _toolTipAdaptor           = null;
 }
Esempio n. 7
0
        public IEnumerable GetItemsToOffer(string text,
                                           IEnumerable items,
                                           IDisplayStringAdaptor adaptor)
        {
            List <Option> show = new List <Option>();

#if !DEBUG
            try
            {
#endif
            //enhance: make that text safe for regex. for now, we just swallow the exception
            string pattern             = @"(^|[^\w])(" + text + @")[^\w]";
            Regex MatchWholeWordNoCase = new Regex(pattern,
                                                   RegexOptions.IgnoreCase | RegexOptions.Compiled);

            foreach (Option option in _allOptions.Options)
            {
                //todo: make this prefferd script(s) savvy
                if (option.Name.GetFirstAlternative().StartsWith(text,
                                                                 StringComparison.
                                                                 CurrentCultureIgnoreCase))
                {
                    show.Add(option);
                }
            }
            foreach (Option option in _allOptions.Options)
            {
                //todo: make this prefferd script(s) savvy
                if (option.Abbreviation.GetFirstAlternative().StartsWith(text, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (!show.Contains(option))
                    {
                        show.Add(option);
                    }
                }
            }

            //this grabs up the DDP examples
            foreach (Option option in _allOptions.Options)
            {
                if (option.GetSearchKeys(_preferredWritingSystemId).Contains(text.ToLower()))
                {
                    if (!show.Contains(option))
                    {
                        show.Add(option);
                    }
                }
            }

            //  if(show.Count == 0)
            {
                foreach (Option option in _allOptions.Options)
                {
                    //todo: make this prefferd script(s) savvy
                    if (MatchWholeWordNoCase.IsMatch(option.Description.GetFirstAlternative()))
                    {
                        if (!show.Contains(option))
                        {
                            show.Add(option);
                        }
                    }
                }
            }
#if !DEBUG
        }

        catch (Exception /*e*/)
        {
            //not worth crashing over some regex problem
        }
#endif
            return(show);
        }