Example #1
0
        private readonly ILookup <string, TextFragment> _dictionary; // lookup by 1st dictionary entry term

        public DictionaryAnnotator(ITextAnnotator termAnnotator, IEnumerable <string> phrases)
        {
            _dictionary = phrases.Select(ph =>
            {
                var frag = new TextFragment(ph);
                termAnnotator.AnnotateText(frag);
                return(frag);
            })
                          .Where(frag => frag.Annotations.Count > 0)
                          .ToLookup(frag => frag.Annotations[0].Term);
        }