Example #1
0
 internal Chat(UltimaServer ultimaServer, Action notifyAction, IConsole console, IKeywordSource keywordSource)
 {
     this.ultimaServer = ultimaServer;
     this.notifyAction = notifyAction;
     this.console      = console;
     keywordParser     = new KeywordParser(keywordSource);
 }
Example #2
0
        public void Should_wrap_keywords()
        {
            var input    = "<div class=\"csharpcode\">\r\nvar i = 5;\r\n</div>";
            var expected = "<div class=\"csharpcode\">\n<span class=\"kwrd\">var</span> i = 5;\n</div>";
            var actual   = new KeywordParser().Parse(input);

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void Should_maintain_quote_gt_and_lt_markup()
        {
            var input    = "<div class=\"csharpcode\">\r\nvar i = <span class=\"str\">&quot;1 &gt; 0!&quot;</span>;\r\n</div>";
            var expected = "<div class=\"csharpcode\">\n<span class=\"kwrd\">var</span> i = <span class=\"str\">&quot;1 &gt; 0!&quot;</span>;\n</div>";
            var actual   = new KeywordParser().Parse(input);

            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public void Should_not_wrap_keywords_in_stringLiterals()
        {
            var input    = "<div class=\"csharpcode\">\r\nvar i = <span class=\"str\">&quot;this var should not be wrapped&quot;</span>;\r\n</div>";
            var expected = "<div class=\"csharpcode\">\n<span class=\"kwrd\">var</span> i = <span class=\"str\">&quot;this var should not be wrapped&quot;</span>;\n</div>";
            var actual   = new KeywordParser().Parse(input);

            Assert.AreEqual(expected, actual);
        }
Example #5
0
        public void Should_not_wrap_keywords_in_comments()
        {
            var input    = "<div class=\"csharpcode\">\r\nvar i = 5;<span class=\"rem\">//this var should not be wrapped</span>\r\n</div>";
            var expected = "<div class=\"csharpcode\">\n<span class=\"kwrd\">var</span> i = 5;<span class=\"rem\">//this var should not be wrapped</span>\n</div>";
            var actual   = new KeywordParser().Parse(input);

            Assert.AreEqual(expected, actual);
        }
Example #6
0
        static IList <Entity> FilterTransactions(IEnumerable <Transaction> transactions, string description, double threshold)
        {
            // Load up our dictinoary of canonized names
            var wordParser = new KeywordParser("Data/Aliases.csv");
            var keywords   = wordParser.Parse(description);

            var matches = new List <Transaction>();

            Console.WriteLine("Filtering transactions...");
            foreach (var item in transactions)
            {
                if (String.IsNullOrWhiteSpace(item.Name))
                {
                    continue;
                }

                var words = wordParser.Parse(item.Name);
                if (words.Length > 0 && words.KeywordMatch(keywords) >= threshold)
                {
                    matches.Add(item);
                }
            }

            var results = new List <Entity>();

            Console.WriteLine("Aggregating transactions...");
            var groups = matches.GroupBy(i => i.filer_id);

            foreach (var group in groups)
            {
                var entity = new Entity
                {
                    Keywords     = keywords,
                    Transactions = group.ToList()
                };
                results.Add(entity);
            }

#if DEBUG
            DumpEntities(results);
#endif
            return(results);
        }
Example #7
0
        static List <Entity> AggregateTransactionsByDonor(IEnumerable <Transaction> transactions)
        {
            var results = new List <Entity>();
            var count   = transactions.Count();
            int i       = 0;

            // Load up our dictinoary of canonized names
            var wordParser = new KeywordParser("Data/Aliases.csv");

            using (var progress = new ProgressBar())
            {
                Console.Write("Aggregating transactions...");
                foreach (var item in transactions)
                {
                    var words = wordParser.Parse(item.Description);
                    if (words.Length > 0)
                    {
                        var entity = BestEntityMatch(results, words, 0.8);
                        if (entity == null)
                        {
                            // If no good entity match, create a new one
                            entity = new Entity
                            {
                                Keywords     = words,
                                Transactions = new List <Transaction>()
                            };
                            results.Add(entity);
                        }
                        entity.Transactions.Add(item);
                    }
                    progress.Report((double)++i / count);
                }
                Console.WriteLine("Done.\n");
#if DEBUG
                DumpEntities(results);
#endif
            }

            return(results);
        }
Example #8
0
 public VariableParserTest()
 {
     KeywordParser  = new KeywordParser();
     VariableParser = new VariableParser(new Dictionary <string, ParameterExpression>(), new Stack <string>());
 }
Example #9
0
 public KeywordParserTest()
 {
     KeywordParser = new KeywordParser();
 }