/// <summary> /// Gets answer containing the question confirmation. /// </summary> /// <param name="reader">The reader containing question wildcard.</param> /// <param name="question">The question.</param> /// <returns>The answer if available, <c>null</c> otherwise.</returns> private TripletTree getAnswerWithQuestionConfirmation(WildcardReader reader, TripletTree question) { var isYesNoQuestion = Predicate.About.Equals(question.Predicate); //TODO better yes no resolving if (!isYesNoQuestion) throw new NotImplementedException(); var questionObject = question.Object as TripletTree; if (reader.HasEvidence) { //there is evidence for the positive answer return questionObject; } else if (reader.HasNegativeEvidence) { return questionObject.Negation; } return null; }
/// <summary> /// Finds best precondition which can be presented to the user according to question /// in the reader. /// </summary> /// <param name="reader">Reader which request is searched.</param> /// <returns>The request if any, <c>null</c> otherwise.</returns> private TripletTree findBestPrecondition(WildcardReader reader) { var preconditions = reader.GetPreconditions().Take(100).ToList(); preconditions.Sort((a, b) => a.Score.CompareTo(b.Score)); var bestCondition = preconditions.Where(p => !_askedPreconditions.Contains(toTriplet(p.Wildcard))).LastOrDefault(); if (bestCondition == null) return null; return toTriplet(bestCondition.Wildcard); }