Created
January 6, 2015 14:53
-
-
Save tankcdr/10a03c8bf261c1bc47d0 to your computer and use it in GitHub Desktop.
loadAnswerData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void loadAnswerData(string question) | |
{ | |
answerData.Clear(); | |
//call Watson | |
var response = this.qaService.AskQuestion(question); | |
//parse JSON response | |
JArray payload = JArray.Parse(response); | |
//obtain answer items we are interested in | |
var answerList = | |
from p in payload[0]["question"]["evidencelist"] | |
select new | |
{ | |
Answer = p["text"], | |
Confidence = p["value"] | |
}; | |
//populate the list box with answers | |
foreach (var a in answerList) | |
{ | |
answerData.Rows.Add(new object[] {a.Answer,a.Confidence}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment