Exemplo n.º 1
0
        public string[] Check(string misspelling)
        {
            List <WordCount> candidates =
                new List <WordCount>();

            // TODO
            List <string> words = CandidateGenerator.GetCandidates(misspelling).ToList();

            foreach (string word in words)
            {
                if (this.LanguageModel.GetCount(word, out ulong count) == true)
                {
                    candidates.Add(new WordCount(word, count));
                }
            }
            return(candidates
                   .OrderByDescending(x => x.Count)
                   .Select(x => x.Word)
                   .Distinct()
                   .ToArray());
        }
Exemplo n.º 2
0
        public string[] Check(string misspelling)
        {
            List <WordCount> candidates =
                new List <WordCount>();

            string[] allCandidates = CandidateGenerator.GetCandidates(misspelling);
            for (long i = 0; i < allCandidates.Length; i++)
            {
                ulong result = FastLM.BisectionSearch(LanguageModel.WordCounts, allCandidates[i]);
                if (result > 0)
                {
                    candidates.Add(new WordCount(allCandidates[i], result));
                }
            }

            return(candidates
                   .OrderByDescending(x => x.Count)
                   .Select(x => x.Word)
                   .Distinct()
                   .ToArray());
        }
Exemplo n.º 3
0
        public string[] Check(string misspelling)
        {
            List <WordCount> candidates =
                new List <WordCount>();

            //TODO

            List <string> oneEditDistance = CandidateGenerator.GetCandidates(misspelling).ToList();

            oneEditDistance.Add(misspelling);

            oneEditDistance.OrderBy(i => i);
            LanguageModel.WordCounts.OrderBy(i => i.Word);

            List <WordCount> finals = new List <WordCount>();

            //NAIVE
            //for (int i = 0; i < oneEditDistance.Count; i++)
            //    for (int j = 0; j < LanguageModel.WordCounts.Length; j++)
            //        if (LanguageModel.WordCounts[j].Word == oneEditDistance[i])
            //            finals.Add(LanguageModel.WordCounts[j]);

            for (int i = 0; i < LanguageModel.WordCounts.Count(); i++)
            {
                int index = BinarySearch(oneEditDistance.ToArray(), 0, oneEditDistance.Count - 1,
                                         LanguageModel.WordCounts[i].Word);

                if (oneEditDistance[index] == LanguageModel.WordCounts[i].Word)
                {
                    finals.Add(LanguageModel.WordCounts[i]);
                }
            }

            return(finals
                   .OrderByDescending(x => x.Count)
                   .Select(x => x.Word)
                   .Distinct()
                   .ToArray());
        }
Exemplo n.º 4
0
        public string[] Check(string misspelling)
        {
            List <WordCount> candidates =
                new List <WordCount>();

            var data          = LanguageModel.WordCounts;
            var checkingWords = CandidateGenerator.GetCandidates(misspelling);

            for (int i = 0; i < checkingWords.Length - 1; i++)
            {
                var temp = BinarySearch(checkingWords[i], data);
                if (temp.Count != 0)
                {
                    candidates.Add(temp);
                }
            }

            return(candidates
                   .OrderByDescending(x => x.Count)
                   .Select(x => x.Word)
                   .Distinct()
                   .ToArray());
        }
Exemplo n.º 5
0
        public string[] Check(string misspelling)
        {
            List <WordCount> candidates =
                new List <WordCount>();

            var arr = CandidateGenerator.GetCandidates(misspelling);

            foreach (var item in arr)
            {
                ulong count = 0;
                if (LanguageModel.GetCount(item, out count) == true)
                {
                    candidates.Add(new WordCount(item, count));
                }
            }


            return(candidates
                   .OrderByDescending(x => x.Count)
                   .Select(x => x.Word)
                   .Distinct()
                   .ToArray());
        }