Example #1
0
 private static IEnumerable <WordSuggestion> ParseSuggestions(JdictSuggestions jdictSuggestions)
 => jdictSuggestions.List.Select(suggestion =>
                                 new WordSuggestion()
 {
     Word    = $"{suggestion.Word} / {suggestion.Kana}",
     Meaning = suggestion.SuggestMean.Replace("  ", " "),         //remove weird typos.
 });
Example #2
0
        public async Task <IEnumerable <WordSuggestion> > Get(string word)
        {
            var response = await SendSuggestionsRequest(word);

            if (!response.IsSuccessStatusCode)
            {
                throw new HttpRequestException($"Failed to get content. Status code: {response.StatusCode}");
            }

            var rawSuggestions = await response.Content.ReadAsStringAsync();

            JdictSuggestions jdictSuggestions = GetJdictSuggestions(rawSuggestions);

            return(ParseSuggestions(jdictSuggestions));
        }