Esempio n. 1
0
		public async Task<ActionResult> Bluemix(string PerguntaEntrada)
		{

			Bluemix bluemx = new Bluemix();
			AtributosBluemix atributosBlue = new AtributosBluemix();

			

			using (HttpClient http = new HttpClient())
			{

				string url = "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/0235B6x12-nlc-599/classify?text=" + PerguntaEntrada;

				var obj = new { username = "******", password = "******" };

				var byteArray = Encoding.ASCII.GetBytes(String.Concat(obj.username, ":", obj.password));

				var header = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

				http.DefaultRequestHeaders.Authorization = header;

				var a = await http.GetStringAsync(url);

				string[] vSplit = a.Split('\n');

				atributosBlue.SaidaResposta = vSplit[4].Replace("top_class", "");
				atributosBlue.SaidaResposta = atributosBlue.SaidaResposta.Replace(":", "");
				atributosBlue.SaidaResposta = atributosBlue.SaidaResposta.Replace(",", "");
				atributosBlue.SaidaResposta = atributosBlue.SaidaResposta.Replace("\\", "");
				atributosBlue.SaidaResposta = atributosBlue.SaidaResposta.Replace("\"", "");


				atributosBlue.SaidaResposta = bluemx.RetornaRespostaFaq(atributosBlue.SaidaResposta.Trim());

				return View("Bluemix", atributosBlue);


			}


		}
Esempio n. 2
0
		public ActionResult Faq()
		{

			AtributosBluemix atributoBlue = new AtributosBluemix();

			return View("Bluemix",atributoBlue);

		}