示例#1
0
        public WolframAlphaValidationResult ValidateQuery(XmlDocument Resp)
        {
            System.Threading.Thread.Sleep(1);

            XmlNode MainNode = Resp.SelectNodes("/validatequeryresult")[0];

            WA_ValidationResult              = new WolframAlphaValidationResult();
            WA_ValidationResult.Success      = Convert.ToBoolean(MainNode.Attributes["success"].Value);
            WA_ValidationResult.ErrorOccured = Convert.ToBoolean(MainNode.Attributes["error"].Value);
            WA_ValidationResult.Timing       = Convert.ToDouble(MainNode.Attributes["timing"].Value.Replace(".", ","));
            WA_ValidationResult.ParseData    = MainNode.SelectNodes("parsedata")[0].InnerText;
            WA_ValidationResult.Assumptions  = new List <WolframAlphaAssumption>();

            foreach (XmlNode Node in MainNode.SelectNodes("assumptions"))
            {
                System.Threading.Thread.Sleep(1);
                WolframAlphaAssumption Assumption = new WolframAlphaAssumption();
                Assumption.Word = Node.SelectNodes("word")[0].InnerText;
                XmlNode SubNode = Node.SelectNodes("categories")[0];
                foreach (XmlNode ContentNode in SubNode.SelectNodes("category"))
                {
                    System.Threading.Thread.Sleep(1);
                    Assumption.Categories.Add(ContentNode.InnerText);
                }
                WA_ValidationResult.Assumptions.Add(Assumption);
            }
            return(WA_ValidationResult);
        }
 public void AddAssumption(WolframAlphaAssumption Assumption, Boolean CheckForDuplicates = false)
 {
     if (CheckForDuplicates && WA_Assumption.Contains("&substitution=" + HttpUtility.UrlEncode(Assumption.Word)))
     {
         return;
     }
     WA_Assumption += "&assumption=" + HttpUtility.UrlEncode(Assumption.Word);
 }