コード例 #1
0
 public NLUResult(string intent)
 {
     this.type       = NLUResultType.NORMAL;
     this.intent     = intent;
     this.entities   = new List <NLUEntity>();
     this.attributes = new List <AttributePair>();
 }
コード例 #2
0
        public NLUResult(NLUResultType type)
        {
            this.type = type;

            if (type == NLUResultType.QUITDIALOG)
            {
                this.option = 0;
            }
        }
コード例 #3
0
        public async Task <QueryResult> Process(string datastoreName, string userId, string sessionId, string query, RUNNINGMODE runningMode)
        {
            this.userId       = userId;
            this.sessionId    = sessionId;
            this.query        = query;
            this.runningMode  = runningMode;
            this.dQuerier     = new DataQuerier(datastoreName, runningMode);
            this.msgGenerator = new MessageGenerator(runningMode);


            LogInformation(log.Here(), "runningMode", runningMode.ToString());

            ContextManager contextMgmt     = new ContextManager(datastoreName, userId, sessionId);
            bool           isSameDataStore = contextMgmt.GetContext();

            QueryResult result = null;

            if (!isSameDataStore)
            {
                result = this.msgGenerator.GenerateErrorMessage("在本轮对话结束前更改 Datastore 导致之前对话退出。");
                contextMgmt.ExitDialog();
                contextMgmt.UpdateContext();
                return(result);
            }

            NLUResult nlu = new NLUProcessor(datastoreName).Parse(query);

            LogInformation(log.Here(), "nlu", nlu.ToString());

            NLUResultType type = nlu.GetType();

            if (type == NLUResultType.NOTEXIST)
            {
                result = this.msgGenerator.GenerateErrorMessage("无法查找语料,请确认 Datastore 是否存在,以及其中是否有数据。");
                contextMgmt.ExitDialog();
            }
            else if (type == NLUResultType.UNKNOWN && contextMgmt.GetIntent() == null)
            {
                result = this.msgGenerator.GenerateErrorMessage("无法识别意图。");
                contextMgmt.ExitDialog();
            }
            else if (type == NLUResultType.QUITDIALOG)
            {
                result = this.msgGenerator.GenerateQuitMessage();
                contextMgmt.ExitDialog();
            }
            else
            {
                result = ResponseDialog(nlu, contextMgmt);
            }

            contextMgmt.UpdateContext();

            return(result);
        }
コード例 #4
0
        public NLUResult(string intent, List <NLUEntity> entities, List <AttributePair> attributes, HashSet <string> relationTypeSet)
        {
            this.type     = NLUResultType.NORMAL;
            this.intent   = intent;
            this.entities = entities;

            if (attributes != null)
            {
                this.attributes = attributes;
            }

            if (relationTypeSet.Count > 0)
            {
                this.relationTypeSet = relationTypeSet;
            }
        }
コード例 #5
0
        public async Task <QueryResult> Process(string userId, string sessionId, string query, RUNNINGMODE runningMode)
        {
            this.userId       = userId;
            this.sessionId    = sessionId;
            this.query        = query;
            this.runningMode  = runningMode;
            this.dQuerier     = new DataQuerier(runningMode);
            this.msgGenerator = new MessageGenerator(runningMode);


            LogInformation(_log.Here(), "runningMode", runningMode.ToString());

            ContextManager contextMgmt = new ContextManager(userId, sessionId);

            contextMgmt.GetContext();

            NLUResult nlu = new NLUProcessor().Parse(query);

            LogInformation(_log.Here(), "nlu", nlu.ToString());

            NLUResultType type = nlu.GetType();

            QueryResult result = null;

            if (type == NLUResultType.UNKNOWN && contextMgmt.GetIntent() == null)
            {
                result = this.msgGenerator.GenerateErrorMessage("无法识别意图。");
                contextMgmt.ExitDialog();
            }
            else if (type == NLUResultType.QUITDIALOG)
            {
                result = this.msgGenerator.GenerateQuitMessage();
                contextMgmt.ExitDialog();
            }
            else
            {
                result = ResponseDialog(nlu, contextMgmt);
            }

            contextMgmt.UpdateContext();

            return(result);
        }
コード例 #6
0
 public NLUResult(int option)
 {
     this.type   = NLUResultType.NUMBER;
     this.option = option;
 }