Esempio n. 1
0
        public WatsonApiResponse Anaylze(string text)
        {
            ToneInput input = new ToneInput();

            input.Text = text;
            WatsonApiResponse objResponse = new WatsonApiResponse();


            try
            {
                string jsonResponse = toneAnalyzer.Tone(input).ResponseJson;
                objResponse       = WatsonApiResponse.FromJson(jsonResponse);
                objResponse.Error = false;
                if (objResponse.SentencesTone == null)
                {
                    objResponse.SentencesTone = new List <SentencesTone>().ToArray();
                }
            }
            catch
            {
                objResponse.Error     = true;
                objResponse.ErrorText = "Counld not get Watson API data. ";
            }

            return(objResponse);
        }
 public static string ToJson(this WatsonApiResponse self) => JsonConvert.SerializeObject(self, MyJournal.Services.Converter.Settings);