Пример #1
0
        public void GetSuggestionCountTest()
        {
            try
            {
                SwipeType.SwipeType swipeType = new MatchSwipeType(File.ReadAllLines("EnglishDictionary.txt"));
                var testing = new Dictionary <string, List <string> >
                {
                    ["heqerqllo"] = new List <string>
                    {
                        "hello",
                        "hero",
                        "ho"
                    },
                    ["wertyuioiuytrtghjklkjhgfd"] = new List <string>
                    {
                        "weird",
                        "world",
                        "would"
                    },
                    ["dfghjioijhgvcftyuioiuytr"] = new List <string>
                    {
                        "doctor",
                        "door",
                        "dour"
                    },
                    ["asdfgrtyuijhvcvghuiklkjuytyuytre"] = new List <string>
                    {
                        "agriculture",
                        "article",
                        "adjure"
                    }
                };

                foreach (var s in testing)
                {
                    foreach (var x in swipeType.GetSuggestion(s.Key, 3))
                    {
                        s.Value.Remove(x);
                    }
                }

                foreach (var s in testing)
                {
                    if (s.Value.Count > 0)
                    {
                        Assert.Fail("GetSuggestionTest fail with new match");
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail($"GetSuggestionTest fail with exception: {ex}");
            }
        }
Пример #2
0
        private static void Main()
        {
            SwipeType simpleSwipeType = new MatchSwipeType(File.ReadAllLines("EnglishDictionary.txt"));

            SampleUsingSwipeType(simpleSwipeType);
            Console.ReadKey(true);

            SwipeType distanceSwipeType = new DistanceSwipeType(File.ReadAllLines("EnglishDictionary.txt"));

            SampleUsingSwipeType(distanceSwipeType);
            Console.ReadKey(true);
        }
Пример #3
0
 public void SimpleSwipeTypeTest()
 {
     try
     {
         SwipeType.SwipeType swipeType = new MatchSwipeType(File.ReadAllLines("EnglishDictionary.txt"));
     }
     catch (OutOfMemoryException e)
     {
         Assert.Fail($"GetSuggestionTest fail with OutOfMemoryException: {e}");
     }
     catch (Exception ex)
     {
         Assert.Fail($"GetSuggestionTest fail with Exception: {ex}");
     }
 }
Пример #4
0
        public IEnumerable <string> analyzeInputNeargye(Dictionary <long, double[]> moveHistory)
        {
            char test            = '`';
            char consecutiveChar = '0';
            int  counter         = 0;

            try
            {
                List <KeyValuePair <char, int> > list = new List <KeyValuePair <char, int> >();
                for (int i = 0; i < moveHistory.Count(); i++)
                {
                    int count = 1;
                    while (settleButton(moveHistory.ElementAt(i).Value[0], moveHistory.ElementAt(i).Value[1]) == settleButton(moveHistory.ElementAt(i + 1).Value[0], moveHistory.ElementAt(i + 1).Value[1]))
                    {
                        i++;
                        count++;
                        if (i + 1 == moveHistory.Count())
                        {
                            break;
                        }
                    }
                    list.Add(new KeyValuePair <char, int>(settleButton(moveHistory.ElementAt(i).Value[0], moveHistory.ElementAt(i).Value[1]), count));
                }

                for (int i = 0; i < list.Count() - 2; i++)
                {
                    if (i + 2 > list.Count() - 1)
                    {
                        break;
                    }
                    if (list.ElementAt(i + 1).Value < 10 && list.ElementAt(i + 0).Key == list.ElementAt(i + 2).Key)
                    {
                        list.RemoveAt(i + 1);
                    }
                }

                string word = "";
                foreach (var letter in list)
                {
                    if (letter.Value > 0)
                    {
                        for (int i = 0; i < letter.Value; i++)
                        {
                            word += letter.Key;
                        }
                    }
                }

                moveHistory.Clear();
                if (word.Length > 0)
                {
                    var swype = new MatchSwipeType(File.ReadAllLines("EnglishDictionary.txt"));
                    return(swype.GetSuggestion(word, 5));
                }
                else
                {
                    return(null);
                }
            } catch (Exception e)
            {
                return(null);
            }
        }
Пример #5
0
        public void GetSuggestionTest()
        {
            try
            {
                SwipeType.SwipeType swipeType = new MatchSwipeType(File.ReadAllLines("EnglishDictionary.txt"));
                var testing = new Dictionary <string, List <string> >
                {
                    ["heqerqllo"] = new List <string>
                    {
                        "hello",
                        "hero",
                        "ho"
                    },
                    ["qwertyuihgfcvbnjk"] = new List <string>
                    {
                        "quick"
                    },
                    ["wertyuioiuytrtghjklkjhgfd"] = new List <string>
                    {
                        "weird",
                        "world",
                        "would",
                        "weld",
                        "wild",
                        "wold",
                        "word",
                        "wed"
                    },
                    ["dfghjioijhgvcftyuioiuytr"] = new List <string>
                    {
                        "doctor",
                        "door",
                        "dour"
                    },
                    ["aserfcvghjiuytedcftyuytre"] = new List <string>
                    {
                        "architecture",
                        "architecure"
                    },
                    ["asdfgrtyuijhvcvghuiklkjuytyuytre"] = new List <string>
                    {
                        "agriculture",
                        "article",
                        "adjure",
                        "astute"
                    },
                    ["mjuytfdsdftyuiuhgvc"] = new List <string>
                    {
                        "mystic",
                        "music"
                    },
                    ["vghjioiuhgvcxsasdvbhuiklkjhgfdsaserty"] = new List <string>
                    {
                        "vocabulary"
                    }
                };

                foreach (var s in testing)
                {
                    foreach (var x in swipeType.GetSuggestion(s.Key))
                    {
                        s.Value.Remove(x);
                    }
                }

                foreach (var s in testing)
                {
                    if (s.Value.Count > 0)
                    {
                        Assert.Fail("GetSuggestionTest fail with new match");
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail($"GetSuggestionTest fail with exception: {ex}");
            }
        }
Пример #6
0
 private void Start()
 {
     matchSwipeType = new MatchSwipeType(File.ReadAllLines(dictionary)); // File with a list of words
 }
Пример #7
0
 public void SetSwipeType(MatchSwipeType matchSwipeType)
 {
     _selectedSwipeType = matchSwipeType;
     Debug.Log("Set new dictionary");
 }