private ResponseBase edgeHintInput(ParsedUtterance utterance, DialogActBase act)
        {
            if (act.IsDontKnow)
            {
                return(new NotUsefulContinuationAct(startNewFrame()));
            }

            var edgeHint     = utterance.OriginalSentence;
            var intextFormat = getIntextFormat(edgeHint);

            if (act.IsNegate && intextFormat == null)
            {
                return(new RequestWordingAct());
            }

            if (act.IsAffirm)
            {
                //force users to really output something
                if (_initialEdgeHypothesis != _currentEdgeHypothesis)
                {
                    HadInformativeInput = true;
                    CanBeCompleted      = true;
                    _currentEdgeTopic.AddExpression(_currentEdgeHypothesis);
                    return(new UsefulContinuationAct(startNewFrame()));
                }
                else
                {
                    return(new NotUsefulContinuationAct(startNewFrame()));
                }
            }


            if (intextFormat == null)
            {
                var taggedInput = tagEdgeHint(edgeHint);
                if (getWords(taggedInput).Length < 2)
                {
                    return(new DontUnderstandAct());
                }

                if (!taggedInput.Contains(_label1Tag))
                {
                    return(new NoConnectionToEntityAct(entityInfo(_currentEdgeRepresentant.Item1)));
                }

                if (!taggedInput.Contains(_label2Tag))
                {
                    return(new NoConnectionToEntityAct(entityInfo(_currentEdgeRepresentant.Item3)));
                }
            }

            if (intextFormat.Replace(_label1Tag, "").Replace(_label2Tag, "").Trim() == "")
            {
                return(new NotUsefulContinuationAct(startNewFrame()));
            }

            _currentEdgeHypothesis = intextFormat;
            parseCurrentEdgeRepresentant(out string label1, out string requestedRelation, out string edgeHypothesis, out string label2);
            return(new EdgeConfirmationRequestAct(label1, intextFormat, label2));
        }
        private ResponseBase entityLabelHintInput(ParsedUtterance utterance, DialogActBase act)
        {
            if (act.IsAffirm)
            {
                return(new ContinueAct());
            }

            if (act.IsDontKnow || act.IsNegate)
            {
                return(new NotUsefulContinuationAct(startNewFrame()));
            }

            if (act.IsAdvice)
            {
                var advice = act as AdviceAct;
                _currentEntityTopic.AddLabelCandidate(advice.Answer.OriginalSentence);
            }

            HadInformativeInput = utterance.Words.Count() > 2;
            CanBeCompleted      = true;

            // now we are just collecting simple data without any negotiation
            return(new UsefulContinuationAct(startNewFrame()));

            /*var linkedUtterance = _linker.LinkUtterance(utterance.OriginalSentence);
             * if (linkedUtterance.Entities.Count() != 0)
             *  throw new NotImplementedException("maybe noise, relevant entities, etc");
             *
             *
             * throw new NotImplementedException("parse entities");*/
        }
Example #3
0
        /// <summary>
        /// Apply given input on given state.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="state"></param>
        /// <returns>State after input application.</returns>
        private DialogState applyInput(DialogActBase input, DialogState state)
        {
            var processor = new InputProcessor(state);

            input.Visit(processor);

            return(processor.Output);
        }