Exemplo n.º 1
0
        public async Task <GameWrapperClass> Get([FromBody] WordTopic topic)
        {
            IUniqueIdGen     idGen   = new UniqueIdGen <GameWrapperClass>(repo);
            IWordGenerator   wordGen = new ConstentWordGenerator(topic);
            GameWrapperClass newGame = new GameWrapperClass((await idGen.GetUniqueIdAsync(idLengthPolicy)), (await wordGen.GetWordAsync()), triesNo);
            await repo.WriteAsync(newGame);

            return(newGame);
        }
Exemplo n.º 2
0
        public static List <WordTopic> ReturnTopTenWords(string text)
        {
            var regex = new Regex(@"\b(\w+?)\b");

            var listWord   = (from Match match in regex.Matches(text) select match.Groups[1].ToString()).ToList();
            var listReturn = new List <WordTopic>();

            foreach (var grupo in listWord.GroupBy(x => x))
            {
                var w = new WordTopic();
                w.word     = grupo.Key;
                w.ocurrenc = grupo.Count(
                    );

                listReturn.Add(w);
            }


            return(listReturn.OrderByDescending(x => x.ocurrenc).Take(10).ToList());
        }
Exemplo n.º 3
0
 public ConstentWordGenerator(WordTopic topic)
 {
     ChosenCollection = wordsByTopic[topic];
 }