Exemplo n.º 1
0
        /// <summary>
        /// Selects a random word within the first 10000 heaviest connected words of the training word.
        /// </summary>
        /// <returns>The word instance if found, the default end word otherwise.</returns>
        internal WordInstance SelectWord()
        {
            var sortedWords = PostWords.OrderByDescending(td => td.Value.Weight).Take(Math.Min(PostWords.Count, 10000)).ToList();

            if (sortedWords.Count == 0)
            {
                return(DefaultEndWord);
            }

            return(sortedWords[WordRand.Next(0, sortedWords.Count)].Value);
        }
Exemplo n.º 2
0
 public ServerResponse Post([FromBody] PostWords postedWords)
 {
     try
     {
         _wordsService.AddWord(postedWords.SessionId, postedWords.Words);
         _statsService.WordsSubmitted(postedWords.SessionId, postedWords.Words.Length, GetClientIp());
         return(ServerResponse.Success());
     }
     catch (Exception exception)
     {
         return(ServerResponse.Fail(exception.Message));
     }
 }