Пример #1
0
        public override IAnswer Process(IQuestionProcessingContext context)
        {
            var allStatements = context.SemanticNetwork.Statements.Enumerate(context.ActiveContexts);

            IEnumerable <IStatement> statements;
            var parentChild = Statement as IParentChild <IConcept>;

            if (parentChild != null)
            {
                statements = allStatements.FindPath(Statement.GetType(), parentChild.Parent, parentChild.Child);
            }
            else
            {
                var statement = allStatements.FirstOrDefault(p => p.Equals(Statement));
                statements = statement != null ? new[] { statement } : Array.Empty <IStatement>();
            }

            var result = new UnstructuredContainer();

            System.Boolean isTrue = statements.Any();
            result.Append(
                language => Strings.ParamAnswer,
                new Dictionary <String, IKnowledge> {
                { Strings.ParamAnswer, isTrue.ToLogicalValue() }
            });
            result.Append(isTrue ? Statement.DescribeTrue() : Statement.DescribeFalse());
            return(new BooleanAnswer(
                       isTrue,
                       result,
                       new Explanation(statements)));
        }