// ReSharper disable once EmptyConstructor
        internal LanguageProcessor()
        {
            _verbot = new Verbot4Engine();
            var kb  = new KnowledgeBase();
            var kbi = new KnowledgeBaseItem();

            _state = new State();

            //load all current knowledge
            LoadStartingKnowledgeBase();

            //save the knowledgebase
            var xToolbox = new XmlToolbox(typeof(KnowledgeBase));

            xToolbox.SaveXml(kb, @"c:\kbi.vkb");

            //load the knowledgebase item
            kbi.Filename = "kbi.vkb";
            kbi.Fullpath = @"c:\";

            //set the knowledge base for verbot
            _verbot.AddKnowledgeBase(kb, kbi);
            _state.CurrentKBs.Add(@"c:\kbi.vkb");
            Ckb = _verbot.CompileKnowledgeBase(kb, kbi);
        }
Esempio n. 2
0
        public ActionResult New(QuestionAndAnswerModel model)
        {
            //TODO: Return partial view "Entry" with an instance of QuestionAndAnswerModel.
            //If model is valid then persists the new entry on DB. Make sure  data changes are committed.

            try
            {
                if (ModelState.IsValid)
                {
                    //QuestionAndAnswerModel qAA = AutoMapper.Mapper.Map<QuestionAndAnswerModel>(this.KnowledgeBaseQuery.Get(downCast.Id));

                    KnowledgeBaseItem newItem = new KnowledgeBaseItem
                    {
                        Query        = model.Question,
                        Answer       = model.Answer,
                        LastUpdateOn = DateTime.Now,
                        Tags         = model.Tags
                    };
                    this.KnowledgeBaseData.Add(newItem);
                    this.KnowledgeBaseData.CommitChanges();
                }

                return(PartialView(model));
            }
            catch {
                throw new Exception();
            }
        }
 // Use this for initialization
 public void StartVerbot()
 {
     this.verbot = new Verbot5Engine();
     this.state  = new State();
     kb          = new KnowledgeBase();
     kbi         = new KnowledgeBaseItem();
     Debug.Log("Verbot initialized");
 }
Esempio n. 4
0
 public void Put(int id, [FromBody] KnowledgeBaseItem item)
 {
     //item.Id = id;
     //if (!_knowledgeBaseService.UpdateItem(item))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
Esempio n. 5
0
        public HttpResponseMessage Post([FromBody] KnowledgeBaseItem item)
        {
            //item = _knowledgeBaseService.AddItem(item);
            var response = Request.CreateResponse(HttpStatusCode.Created, item);

            string uri = Url.Link("DefaultApi", new { id = item.DomainId });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            // verbot variables
            Verbot5Engine     verbot = new Verbot5Engine();
            KnowledgeBase     kb     = new KnowledgeBase();
            KnowledgeBaseItem kbi    = new KnowledgeBaseItem();
            State             state  = new State();

            // build the knowledgebase
            Rule vRule = new Rule();

            vRule.Id = kb.GetNewRuleId();
            vRule.AddInput("Hello", "");
            vRule.AddInput("Hi", "");
            vRule.AddOutput("Hello, World", "", "");
            kb.Rules.Add(vRule);
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            // save the knowledgebase
            XMLToolbox xToolbox = new XMLToolbox(typeof(KnowledgeBase));

            xToolbox.SaveXML(kb, path + @"\kbi.vkb");

            // load the knowledgebase item
            kbi.Filename = "kbi.vkb";
            kbi.Fullpath = path + @"\";

            // set the knowledge base for verbot
            verbot.AddKnowledgeBase(kb, kbi);

            state.CurrentKBs.Add(path + @"\kbi.vkb");

            // get input
            Console.WriteLine("Please enter your message");

            while (true)
            {
                string msg = Console.ReadLine();

                // process the reply
                Reply reply = verbot.GetReply(msg, state);
                if (reply != null)
                {
                    Console.WriteLine(reply.AgentText);
                }
                else
                {
                    Console.WriteLine("No reply found.");
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the tree from the child to the root parent, including all childs of each parent
        /// </summary>
        /// <param name="childId">The child identifier.</param>
        /// <returns></returns>
        public KnowledgeBaseItem GetRootTreeFromChild(Guid childId)
        {
            var item = _unitOfWork.KbItems.Fetch(i => i.DomainId == childId).Single();

            // Get all parents
            while (item.ParentItemId.HasValue)
            {
                item = _unitOfWork.KbItems.GetById(item.ParentItemId.Value);
                if (item.ParentItemId.HasValue)
                {
                    // Get all items that share this parent
                    var parentItemId = item.ParentItemId.Value;
                    var childs       = _unitOfWork.KbItems.Fetch(
                        i => i.Name,
                        i => i.ParentItemId == parentItemId)
                                       .ToList();
                    item = childs.First();
                }
            }

            return(KnowledgeBaseItem.FromKbItem(item));
        }
        private FaqItemViewModel CreateFaQViewItemModel(KnowledgeBaseGroup parentGroup, KnowledgeBaseItem item)
        {
            _helpdeskProvider.KnowledbaseView(item);

            List <BreadcrumbItem> crumbs = GetBreadcrumbs().Take(2).ToList();

            crumbs.Add(new BreadcrumbItem(Languages.LanguageStrings.FrequentlyAskedQuestions, $"/{Name}/{nameof(FaQ)}/", false));

            crumbs.Add(new BreadcrumbItem(parentGroup.Name,
                                          $"/{Name}/{nameof(FaQ)}/{parentGroup.Id}/{BaseModel.RouteFriendlyName(parentGroup.Name)}/", true));

            KnowledgeBaseGroup currGroup = parentGroup.Parent;

            while (currGroup != null)
            {
                crumbs.Insert(3, new BreadcrumbItem(currGroup.Name,
                                                    $"/{Name}/{nameof(FaQ)}/{currGroup.Id}/{BaseModel.RouteFriendlyName(currGroup.Name)}/", true));
                currGroup = currGroup.Parent;
            }

            BaseModelData modelData = GetModelData();

            modelData.ReplaceBreadcrumbs(crumbs);

            return(new FaqItemViewModel(modelData,
                                        KnowledgeBaseToFaQGroup(parentGroup), item.Description, item.ViewCount,
                                        FormatTextForDisplay(item.Content)));
        }