Beispiel #1
0
        private List <string> CreateCombinationsWord(string word)
        {
            var combinations = _diacriticAdder.Start(word.ToLower(), 100);
            var result       = (from kvp in combinations select kvp.Key).Distinct().ToList();

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Create the variants.
        /// </summary>
        internal void CreateVariants(List <string> dictionary)
        {
            NgramVariants = new List <NGramVariant>();
            var lists = new List <List <string> >();

            foreach (var item in OrginalNGram.WordsList)
            {
                lists.Add(new List <string>());
                var index        = lists.Count - 1;
                var combinations = _marksAdder.Start(item.ToLower(), 100);
                foreach (var combination in combinations)
                {
                    foreach (var word in dictionary)
                    {
                        if (combination.Key == word)
                        {
                            lists[index].Add(combination.Key);
                        }
                    }
                }

                if (lists[index].Count == 0)
                {
                    lists[index].Add(item.ToLower());
                }
            }

            var res = lists[lists.Count - 1];

            for (var i = lists.Count - 1; i > 0; --i)
            {
                res = Permutation(lists[i - 1], res);
            }

            foreach (var sequence in res)
            {
                NgramVariants.Add(new NGramVariant {
                    Ngram = new NGram(0, sequence.Split(' ').ToList()), Probability = 0
                });
            }
        }