public void FilterUserDataTest()
        {
            UserDataFilterService filterService = new UserDataFilterService();

            string testText = "My phone number is 800-555-1212. email: [email protected] got it? name: My name is Mike.";

            string filtered = filterService.FilterUserData(null, testText, true);

            Assert.AreEqual(filtered, "My phone number is <PHONE>. email: <EMAIL>.com got it? name: My name is Mike.");

            filtered = filterService.FilterUserData(null, testText, false);
            Assert.AreEqual(filtered, "My phone number is . email: .com got it? name: My name is Mike.");
        }
        public void FilterUserDataShortNameTest()
        {
            ChatState             state         = new ChatState();
            UserDataFilterService filterService = new UserDataFilterService();

            state.AddPIIText(ChatWeb.Models.PIIType.Low, "mary", "NAME");
            state.AddPIIText(ChatWeb.Models.PIIType.Low, "n", "NAME");

            string testText = "My name is mary n.";

            string filtered = filterService.FilterUserData(state, testText, true);

            Assert.AreEqual(filtered, "My name is <NAME> n.");
        }
Ejemplo n.º 3
0
        public override async Task <ParseResult> ParseAsync(ChatState chatState, Chat_ParseField chatParseField, ChatMessage message)
        {
            // Strip PII data
            string text        = filterService.FilterUserData(chatState, message.CorrectedUserInput, false);
            string classifiers = chatParseField?.GetProperty("Classifiers") ?? defaultClassifier;

            message.Classifications = await classificationService.ClassifyAsync(classifiers, threshold, text, false, chatState.SessionData.IsSmsChannel);

            chatState.UpdateLastClassification(message.Classifications);

            if (message.Classifications.IsSuccessful)
            {
                // We don't want common chat intent's here.
                if (message.Classifications.GetBestResult().Intent.StartsWith("commonchat-"))
                {
                    return(ParseResult.Failed);
                }

                return(ParseResult.CreateSuccess(message.Classifications.GetBestResult().Intent));
            }

            return(ParseResult.Failed);
        }