Пример #1
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <ComparisonQuestion, ComparisonStatement>()
            .WithTransitives(s => s.Count == 0, GetNestedQuestions)
            .Where(s => (s.LeftValue == LeftValue && s.RightValue == RightValue) || (s.RightValue == LeftValue && s.LeftValue == RightValue))
            .SelectCustom(CreateAnswer));
 }
Пример #2
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <ProcessesQuestion, ProcessesStatement>()
            .WithTransitives(s => s.Count == 0, GetNestedQuestions)
            .Where(s => (s.ProcessA == ProcessA && s.ProcessB == ProcessB) || (s.ProcessB == ProcessA && s.ProcessA == ProcessB))
            .SelectCustom(CreateAnswer));
 }
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <EnumerateContainersQuestion, HasPartStatement>()
            .Where(s => s.Part == Concept)
            .SelectAllConcepts(
                statement => statement.Whole,
                question => question.Concept,
                Semantics.Localization.Strings.ParamChild,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.EnumerateContainers));
 }
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <EnumerateDescendantsQuestion, IsStatement>()
            .Where(s => s.Ancestor == Concept)
            .SelectAllConcepts(
                statement => statement.Descendant,
                question => question.Concept,
                Strings.ParamParent,
                language => language.GetExtension <ILanguageClassificationModule>().Questions.Answers.EnumerateDescendants));
 }
Пример #5
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <FindSubjectAreaQuestion, GroupStatement>()
            .Where(s => s.Concept == Concept)
            .SelectAllConcepts(
                statement => statement.Area,
                question => question.Concept,
                Semantics.Localization.Strings.ParamConcept,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.SubjectArea));
 }
Пример #6
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <DescribeSubjectAreaQuestion, GroupStatement>()
            .Where(s => s.Area == Concept)
            .SelectAllConcepts(
                statement => statement.Concept,
                question => question.Concept,
                Strings.ParamArea,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.SubjectAreaConcepts));
 }
Пример #7
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <IsValueQuestion, SignValueStatement>()
            .Where(s => s.Value == Concept)
            .SelectBoolean(
                statements => Concept.HasAttribute <IsValueAttribute>(),
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.ValueTrue,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.ValueFalse,
                new Dictionary <String, IKnowledge>
     {
         { Semantics.Localization.Strings.ParamConcept, Concept },
     }));
 }
Пример #8
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <CustomQuestion, CustomStatement>()
            .Where(s => s.Concept1 == Concept1 && s.Concept2 == Concept2)
            .SelectBoolean(
                statements => statements.Count > 0,
                language => language.GetExtension <ILanguageCustomModule>().Questions.Answers.CustomTrue,
                language => language.GetExtension <ILanguageCustomModule>().Questions.Answers.CustomFalse,
                new Dictionary <String, IKnowledge>
     {
         { CustomStatement.ParamConcept1, Concept1 },
         { CustomStatement.ParamConcept2, Concept2 },
     }));
 }
Пример #9
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <IsPartOfQuestion, HasPartStatement>()
            .Where(s => s.Whole == Parent && s.Part == Child)
            .SelectBoolean(
                statements => statements.Any(),
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.IsPartOfTrue,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.IsPartOfFalse,
                new Dictionary <String, IKnowledge>
     {
         { Semantics.Localization.Strings.ParamParent, Parent },
         { Semantics.Localization.Strings.ParamChild, Child },
     }));
 }
Пример #10
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <IsSubjectAreaQuestion, GroupStatement>()
            .Where(s => s.Area == Area && s.Concept == Concept)
            .SelectBoolean(
                statements => statements.Any(),
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.IsSubjectAreaTrue,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.IsSubjectAreaFalse,
                new Dictionary <String, IKnowledge>
     {
         { Strings.ParamArea, Area },
         { Semantics.Localization.Strings.ParamConcept, Concept },
     }));
 }
Пример #11
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <EnumerateSignsQuestion, HasSignStatement>()
            .WithTransitives(
                statements => Recursive,
                question => question.Concept,
                newSubject => new EnumerateSignsQuestion(newSubject, true),
                needToAggregateTransitivesToStatements: true)
            .Where(s => s.Concept == Concept)
            .SelectAllConcepts(
                statement => statement.Sign,
                question => question.Concept,
                Semantics.Localization.Strings.ParamConcept,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.ConceptSigns + (Recursive ? language.Questions.Answers.RecursiveTrue : language.Questions.Answers.RecursiveFalse) + ": "));
 }
Пример #12
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <HasSignsQuestion, HasSignStatement>()
            .WithTransitives(
                statements => Recursive,
                question => question.Concept,
                newSubject => new HasSignsQuestion(newSubject, true))
            .Where(s => s.Concept == Concept)
            .SelectBooleanIncludingChildren(
                statements => statements.Count > 0,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.HasSignsTrue + (Recursive ? language.Questions.Answers.RecursiveTrue : language.Questions.Answers.RecursiveFalse) + ".",
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.HasSignsFalse + (Recursive ? language.Questions.Answers.RecursiveTrue : language.Questions.Answers.RecursiveFalse) + ".",
                new Dictionary <String, IKnowledge>
     {
         { Semantics.Localization.Strings.ParamConcept, Concept },
     }));
 }
Пример #13
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <IsQuestion, IsStatement>()
            .WithTransitives(
                statements => statements.Count == 0,
                question => question.Child,
                newSubject => new IsQuestion(newSubject, Parent))
            .Where(s => s.Parent == Parent && s.Child == Child)
            .SelectBooleanIncludingChildren(
                statements => statements.Count > 0,
                language => language.GetExtension <ILanguageClassificationModule>().Questions.Answers.IsTrue,
                language => language.GetExtension <ILanguageClassificationModule>().Questions.Answers.IsFalse,
                new Dictionary <String, IKnowledge>
     {
         { Strings.ParamParent, Parent },
         { Strings.ParamChild, Child },
     }));
 }
Пример #14
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <SignValueQuestion, SignValueStatement>()
            .WithTransitives(
                statements => statements.Count == 0,
                question => question.Concept,
                newSubject => new SignValueQuestion(newSubject, Sign))
            .Where(s => s.Concept == Concept && s.Sign == Sign)
            .SelectFirstConcept(
                statement => statement.Value,
                language => language.GetExtension <ILanguageSetModule>().Questions.Answers.SignValue,
                statement => new Dictionary <String, IKnowledge>
     {
         { Semantics.Localization.Strings.ParamConcept, Concept },
         { Strings.ParamSign, statement.Sign },
         { Strings.ParamValue, statement.Value },
         { Strings.ParamDefined, statement.Concept },
     }));
 }
Пример #15
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <GetShorterQuestion, IsTallerThanStatement>()
            .WithTransitives(
                statements => true,
                c => c.SemanticNetwork.Statements
                .OfType <IsTallerThanStatement>()
                .Where(s => s.TallerPerson == c.Question.Person)
                .Select(s => new NestedQuestion(
                            new GetShorterQuestion(s.ShorterPerson),
                            new IStatement[] { s })),
                true)
            .Where(s => s.TallerPerson == Person)
            .SelectAllConcepts(
                statement => statement.ShorterPerson,
                question => question.Person,
                "#TALLER#",
                language => $"#TALLER# is taller than",
                concepts => concepts.Distinct()));
 }
Пример #16
0
 public override IAnswer Process(IQuestionProcessingContext context)
 {
     return(context
            .From <IsTallerQuestion, IsTallerThanStatement>()
            .WithTransitives(
                statements => true,
                c => c.SemanticNetwork.Statements
                .OfType <IsTallerThanStatement>()
                .Where(s => s.TallerPerson == c.Question.TallerPerson)
                .Select(s => new NestedQuestion(
                            new IsTallerQuestion(s.ShorterPerson, c.Question.ShorterPerson),
                            new IStatement[] { s })))
            .Where(s => s.TallerPerson == TallerPerson && s.ShorterPerson == ShorterPerson)
            .SelectBooleanIncludingChildren(
                statements => statements.Count > 0,
                language => "Yes, #TALLER# is taller than #SHORTER#.",
                language => "No, #SHORTER# is taller than #TALLER#.",
                new Dictionary <String, IKnowledge>
     {
         { "#TALLER#", TallerPerson },
         { "#SHORTER#", ShorterPerson },
     }));
 }