Example #1
0
        /// <summary>
        /// 한 문장의 intent를 반환하는 method
        /// </summary>
        /// <param name="subject">문장하나</param>
        /// <returns></returns>
        public string GetMailIent(string subject)
        {
            IntentEntity ie = IsImportance(subject);

            if (ie != null)
            {
                return(ie.returnMessage);
            }
            else
            {
                return(string.Empty);
            }
        }
Example #2
0
        /// <summary>
        /// mail item added event handler ****
        /// </summary>
        /// <param name="Item"></param>
        public string GetMailIent(string subject, string body)
        {
            string strReturn = string.Empty;
            string strBody   = string.Empty;

            // subject intent
            IntentEntity subjectImportance = IsImportance(subject);

            if (subjectImportance != null)
            {
                return(subjectImportance.returnMessage);
            }

            // body intent
            strBody = GetRealBody(body);
            List <string>       sentences   = GetSentences(strBody);
            List <IntentEntity> bodyIntents = new List <IntentEntity>();

            try
            {
                string strTemp = string.Empty;
                foreach (string sentence in sentences)
                {
                    strTemp = helper.GetAibrilResponse(sentence);
                    if (GetConfidenceFromResponse(strTemp) > importanceLevel && GetIntentFromResponse(strTemp).ToLower() != "other")
                    {
                        bodyIntents.Add(new IntentEntity(true, GetIntentFromResponse(strTemp), GetConfidenceFromResponse(strTemp)));
                    }
                }
            }
            catch (Exception e) // maybe network, timeout etc.
            {
                Log(e.Message);
            }

            IntentEntity ieBody = IsImportance(bodyIntents);

            if (ieBody != null)
            {
                if (ieBody.confidence > importanceLevel)
                {
                    strReturn = ieBody.returnMessage;
                }
            }

            return(strReturn);
        }
Example #3
0
        private IntentEntity IsImportance(List <IntentEntity> intents)
        {
            IntentEntity ie = null;

            // 1. sorting
            intents.Sort();
            if (intents.Count != 0)
            {
                if (intents[0].confidence > importanceLevel)
                {
                    ie = intents[0];
                }
            }
            // 2. sum by intent
            // for multi intents
            return(ie);
        }
Example #4
0
        private IntentEntity IsImportance(string subject)
        {
            // 1. 중요 말머리 경우
            string[]     dicImportanceSubject = { "[중요]", "[Important]", "[긴급]", "[요청]", "[문의]", "[필수]" };
            IntentEntity roIntent             = null;

            foreach (string dicImportant in dicImportanceSubject)
            {
                if (subject.StartsWith(dicImportant))
                {
                    roIntent = new IntentEntity(true, "dicImportant", 1, "Important(" + dicImportant + "): 100%");
                }
            }
            // 2. Aibril API
            string strTemp = helper.GetAibrilResponse(subject);

            if (GetConfidenceFromResponse(strTemp) > importanceLevel && GetIntentFromResponse(strTemp).ToLower() != "other")
            {
                roIntent = new IntentEntity(true, GetIntentFromResponse(strTemp), GetConfidenceFromResponse(strTemp));
            }
            return(roIntent);
        }