示例#1
0
        private KeywordProcessor GetSimpleProcessor()
        {
            var kp = new KeywordProcessor();

            kp.AddKeywords(new [] { ".NET Core", "Java", "C语言", "字典 tree", "CET-4", "网络 编程" });
            return(kp);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string to = Request["To"].ToString();
            string body = Request["Body"].ToString();
            string from = Request["From"].ToString();

            var docStore = Application["DocumentStore"] as DocumentStore;
            var repository = new RavenDBRepository(docStore);
            var accountController = new AccountController();
            var users = accountController.GetActiveUsers(repository);

            var keywordProcessor = new KeywordProcessor(docStore);
            var message = keywordProcessor.SetActiveUsersForMatch(users)
                                            .MatchReplyToOriginalMessage(body, from);

            using (var session = docStore.OpenSession())
            {
                var step = session.Load<Step>(message.SubjectMatterId);
                step.Answer = message.UserAnswer;
                step.AnswerDate = DateTime.Now;
                string json = JsonConvert.SerializeObject(step);

                var workflowController = new WorkflowController();
                workflowController.ProcessStep(json, repository,
                                                   Application["Registry"] as RavenFilterRegistry<Step>,
                                                   message.UserId);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string to   = Request["To"].ToString();
            string body = Request["Body"].ToString();
            string from = Request["From"].ToString();

            var docStore          = Application["DocumentStore"] as DocumentStore;
            var repository        = new RavenDBRepository(docStore);
            var accountController = new AccountController();
            var users             = accountController.GetActiveUsers(repository);

            var keywordProcessor = new KeywordProcessor(docStore);
            var message          = keywordProcessor.SetActiveUsersForMatch(users)
                                   .MatchReplyToOriginalMessage(body, from);

            using (var session = docStore.OpenSession())
            {
                var step = session.Load <Step>(message.SubjectMatterId);
                step.Answer     = message.UserAnswer;
                step.AnswerDate = DateTime.Now;
                string json = JsonConvert.SerializeObject(step);

                var workflowController = new WorkflowController();
                workflowController.ProcessStep(json, repository,
                                               Application["Registry"] as RavenFilterRegistry <Step>,
                                               message.UserId);
            }
        }
示例#4
0
        public void TestCreateProcessor()
        {
            var kp = new KeywordProcessor();

            kp.AddKeyword("Big Apple", cleanName: "New York");

            Assert.That(kp.CaseSensitive, Is.False);
            Assert.That(kp.Contains("Big"), Is.False);
            Assert.That(kp.Contains("Big Apple"), Is.True);
        }
示例#5
0
        public void TestExtractSpans()
        {
            var kp = new KeywordProcessor();

            kp.AddKeywords(new [] { "Big Apple", "Bay Area" });
            var keywords = kp.ExtractKeywordSpans("I love Big Apple and Bay Area.");
            var expected = new List <TextSpan> {
                new TextSpan("Big Apple", 7, 16), new TextSpan("Bay Area", 21, 29)
            };

            CollectionAssert.AreEqual(expected, keywords);
        }
示例#6
0
        public void TestExtract()
        {
            var kp = new KeywordProcessor();

            kp.AddKeywords(new [] { "Big Apple", "Bay Area" });
            var keywords = kp.ExtractKeywords("I love Big Apple and Bay Area.");
            var expected = new List <string> {
                "Big Apple", "Bay Area"
            };

            CollectionAssert.AreEqual(expected, keywords);
        }
        public string requestDatabaseObjectInfo(string objectName, string schemaName)
        {
            try
            {
                using (var sqlConn = openConnection(connectionString))
                {
                    DbObject dbObject = null;
                    try
                    {
                        dbObject = sqlConn.Query <DbObject>(Resources.queryObjectInfo_sql, new { objectName = objectName, schemaName = schemaName }).Single();
                    } catch (InvalidOperationException)
                    {
                        return($"object '{schemaName}.{objectName}' not exists");
                    }

                    if (dbObject.type_desc == "USER_TABLE")
                    {
                        var objXml    = sqlConn.Query <String>(Resources.queryTableXml_sql, new { objectName = objectName, schemaName = schemaName }).ToList();
                        var xmlSource = new XmlDocument();
                        xmlSource.LoadXml(String.Join("", objXml));
                        var htmlDest = new StringBuilder();
                        xslTranCompiler.Transform(xmlSource, XmlWriter.Create(htmlDest));
                        return(htmlDest.ToString());
                    }

                    if (objectName != "")
                    {
                        Dictionary <string, string> depList = sqlConn
                                                              .Query <DbDependentObject>(Resources.queryObjectDependancies_sql, new { objectFullName = $"{schemaName}.{objectName}" })
                                                              .Where(dep => dep.num == 1)
                                                              .ToDictionary(dep => dep.referenced_entity_name.ToLower(), dep => dep.buildSqlServerObjectLink());

                        var dependencyProcessor       = new DependencyProcessor(depList);
                        var keywordProcessor1         = new KeywordProcessor(dependencyProcessor, keywords1, "<b style='color:blue'>{0}</b>");
                        var keywordProcessor2         = new KeywordProcessor(keywordProcessor1, keywords2, "<span style='color:magenta'>{0}</span>");
                        var tempTableProcessor        = new BlockProcessor(keywordProcessor2, @"@{1,2}\w+", "<span style='color:dimgray'>{0}</span>");
                        var varableProcessor          = new BlockProcessor(tempTableProcessor, @"\#{1,2}\w+", "<span style='color:dimgray'>{0}</span>");
                        var singleCommentProcessor    = new BlockProcessor(varableProcessor, @"--.*[\r\n]", "<b style='color:green'>{0}</b>");
                        var commentAndStringProcessor = new CommentAndStringProcessor(singleCommentProcessor);
                        return(commentAndStringProcessor.Process(dbObject.object_text));
                    }
                }
                return("unknown type of object");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex}");
                return($"Exception: {ex}");
            }
        }
示例#8
0
        public void TestRemoveKeyword()
        {
            var kp = new KeywordProcessor();

            kp.AddKeyword(".net core");
            kp.AddKeyword("C# 8.0");
            kp.AddKeywords(new [] { "C# 7.0", "C# 8.0" });

            var keywords = kp.ExtractKeywords("I am learning .net core and c# 8.0");
            var expected = new List <string> {
                ".net core", "C# 8.0"
            };

            CollectionAssert.AreEqual(expected, keywords);

            Assert.That(kp.Contains("C# 8.0"), Is.True);
            kp.RemoveKeyword("C# 8.0");
            Assert.That(kp.Contains("C# 8.0"), Is.False);
            keywords = kp.ExtractKeywords("I am learning .net core and c# 8.0");
            expected = new List <string> {
                ".net core"
            };
            CollectionAssert.AreEqual(expected, keywords);
        }