Example #1
0
        /// <summary>
        /// Adds the specified item to an index using the specified string.
        /// </summary>
        public void Add(T item, int indexId, int wsId, string text)
        {
            SortKeyIndex index = GetIndex(indexId, wsId);

            switch (m_type)
            {
            case SearchType.Exact:
            case SearchType.Prefix:
                index.Add(m_sortKeySelector(wsId, text), item);
                break;

            case SearchType.FullText:
                foreach (string token in RemoveWhitespaceAndPunctTokens(m_tokenizer(wsId, text)))
                {
                    index.Add(m_sortKeySelector(wsId, token), item);
                }
                break;
            }
        }
        private void Add(int indexId, int wsId, string text, T item)
        {
            SortKeyIndex   index    = GetIndex(indexId, wsId);
            IWritingSystem ws       = m_wsManager.Get(wsId);
            ICollator      collator = ws.Collator;

            switch (m_type)
            {
            case SearchType.Exact:
            case SearchType.Prefix:
                index.Add(collator.GetSortKey(text).KeyData, item);
                break;

            case SearchType.FullText:
                foreach (string token in Icu.Split(Icu.UBreakIteratorType.UBRK_WORD, ws.IcuLocale, text))
                {
                    index.Add(collator.GetSortKey(token).KeyData, item);
                }
                break;
            }
        }