Exemplo n.º 1
0
 protected void ServerValidateFormat(object source, ServerValidateEventArgs args)
 {
     try
     {
         List <int> quantityListTest = new QuantityExtractor(returnedMovieTable).ExtractQuantityList();
         args.IsValid = true;
     }
     catch
     {
         args.IsValid = false;
     }
 }
Exemplo n.º 2
0
 protected void ServerValidateInRange(object source, ServerValidateEventArgs args)
 {
     try
     {
         List <int> quantityListTest = new QuantityExtractor(returnedMovieTable).ExtractQuantityList();
         try
         {
             bool quantityListOutOfRange = quantityListTest.IntegersOutOfRange(254);
             args.IsValid = !quantityListOutOfRange;
         }
         catch
         {
             args.IsValid = false;
         }
     }
     catch
     {
     }
 }
Exemplo n.º 3
0
 protected void ServerValidateNoNegatives(object source, ServerValidateEventArgs args)
 {
     try
     {
         List <int> quantityListTest = new QuantityExtractor(returnedMovieTable).ExtractQuantityList();
         try
         {
             bool quantityListContainsNegatives = quantityListTest.ContainsNegativeValues();
             args.IsValid = !quantityListContainsNegatives;
         }
         catch
         {
             args.IsValid = false;
         }
     }
     catch
     {
     }
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            string pattern = @"/[\d(\,|\.)?\d]+\s?(tons|mt|ton|kg|kgs|dwt|mts|mtons)/gi";

            // List <Email> emails = DBHelper.RetrieveAllEmails(50);
            // //Console.WriteLine(email.Body);
            // Regex regex = new Regex("sample pattern");
            // foreach (var email in emails)
            // {
            //     string[] lines = email.Body.Split("\n");

            //     foreach (var line in lines)
            //     {
            //         Console.WriteLine(line);
            //         Console.WriteLine("=================================================");
            //         regex.Match(line);
            //     }

            //     Console.WriteLine("######################################\n");
            // }
            // List<string> entities = null;
            // Email email = DBHelper.retrieveEmail(50000);
            // var emailLines = email.Body.Split(new [] { '\r', '\n' });
            // foreach (var emailLine in emailLines)
            // {
            //     string classification = CmdExecutor.run_cmd("python3 classifier.py "+emailLine);
            //     // switch (classification)
            //     // {
            //     //     case "Quantity": PatternQuantiy.Match();
            //     //     case "Description": PatternCargodescription.Match();
            //     //     case "Ld rate": PatternLdRate.Match();
            //     //     case "Laycan date": PatternLaycanDate.Match();
            //     //     case "Commision":PatternCommision.Match();
            //     //     case "Ports": PatternPort.Match();
            //     //     case "Ports Quantity": PatternPortQuantity.Match();
            //     //     default:
            //     // }
            //     entities.Add();
            // }
            //DBHelper.InsertEmailLines();
            // MatchCollection result = null;
            // IEnumerable <Regex> regexdescription =PatternCargodescription();
            // foreach (var line in emailLines)
            // {
            //     foreach (var regex in regexdescription)
            //     {
            //         result = regex.Matches(line);
            //         foreach (var item in result)
            //         {
            //             Console.WriteLine("match :"+item);
            //         }
            //     }
            // }

            List <string> test = new List <string>();

            test.Add("8/15,000 MT BULK MINERALS");
            test.Add("10,000 MT BULK MINERALS");
            test.Add("1 X  ABT  9,500 MT BULK MINERALS");
            test.Add("1 X  ABT 10,000 MT BULK MINERALS");
            test.Add("1 OR 2 LOTS OF 10,000 MT BULK MINERALS");
            test.Add("50000 mts bagged UREA 50kg bags");
            // foreach (var item in test)
            // {
            //     if(Regex.Match("8/15,000 MT BULK MINERALS", @"/(ABT)/gi").Success)
            //     Console.WriteLine(Regex.Match(item, pattern).Value);
            //     else{
            //         Console.WriteLine(Regex.Match(item, pattern).Success);
            //     }
            // }
            QuantityExtractor.extract(test);
        }