protected override void initializeAbilities()
        {
            SpecifiedSlot  = newField <string>("specifiedSlot", _specifiedSlot);
            SpecifiedValue = newField <string>("specifiedValue", _specifiedValue);
            CountValue     = newField <int>("countValue", _countValue);

            this
            .AddAbility("set " + _databaseName + " specifier $specifier").CallAction(_ability_setSpecifier)
            .Param(SpecifiedSlot, "$specifier")
            .Param(SpecifiedValue, "$specifier")

            .AddAnswer("value of $slot from " + _databaseName + " database", Question.HowToEvaluate).Call(_value_slotValue)
            .Param(SpecifiedSlot, "$slot")

            .AddAnswer(_databaseName + " database has $count result", Question.IsItTrue).Call(_value_resultCountCondition)
            .Param(CountValue, "$count")
            ;

            // register all values
            foreach (var column in _externalDatabase.Columns)
            {
                Container.AddSpanElement(column);
                foreach (var value in _externalDatabase.GetColumnValues(column))
                {
                    Container.AddSpanElement(value);
                    Container.Add(SemanticItem.From(Question.WhatItSpecifies, column, Constraints.WithInput(value)));
                }
            }
        }
Пример #2
0
        private void _ability_acceptAdvice(string answer)
        {
            var query   = _askedQuestion;
            var newFact = SemanticItem.From(query.Question, answer, query.Constraints);

            Log.NewFact(newFact);
            _body.Db.Container.Add(newFact);
            _body.Print("ok");

            _askedQuestion = null;
            FireEvent("advice was received");
        }