示例#1
0
        /// <summary>Execute with no arguments for usage.</summary>
        public static void Main(string[] args)
        {
            if (!ValidateCommandLine(args))
            {
                log.Info(Usage());
                System.Environment.Exit(-1);
            }
            DateTime startTime = new DateTime();

            System.Console.Out.WriteLine("##################################");
            System.Console.Out.WriteLine("# Stanford Treebank Preprocessor #");
            System.Console.Out.WriteLine("##################################");
            System.Console.Out.Printf("Start time: %s%n", startTime);
            System.Console.Out.Printf("Configuration: %s%n%n", configFile);
            ConfigParser cp = new ConfigParser(configFile);

            cp.Parse();
            DistributionPackage distrib = new DistributionPackage();

            foreach (Properties dsParams in cp)
            {
                string nameOfDataset = PropertiesUtils.HasProperty(dsParams, ConfigParser.paramName) ? dsParams.GetProperty(ConfigParser.paramName) : "UN-NAMED";
                if (outputPath != null)
                {
                    dsParams.SetProperty(ConfigParser.paramOutputPath, outputPath);
                }
                IDataset ds = GetDatasetClass(dsParams);
                if (ds == null)
                {
                    System.Console.Out.Printf("Unable to instantiate TYPE for dataset %s. Check the javadocs%n", nameOfDataset);
                    continue;
                }
                bool shouldDistribute = dsParams.Contains(ConfigParser.paramDistrib) && bool.ParseBoolean(dsParams.GetProperty(ConfigParser.paramDistrib));
                dsParams.Remove(ConfigParser.paramDistrib);
                bool lacksRequiredOptions = !(ds.SetOptions(dsParams));
                if (lacksRequiredOptions)
                {
                    System.Console.Out.Printf("Skipping dataset %s as it lacks required parameters. Check the javadocs%n", nameOfDataset);
                    continue;
                }
                ds.Build();
                if (shouldDistribute)
                {
                    distrib.AddFiles(ds.GetFilenames());
                }
                if (Verbose)
                {
                    System.Console.Out.Printf("%s%n", ds.ToString());
                }
            }
            if (MakeDistrib)
            {
                distrib.Make(distribName);
            }
            if (Verbose)
            {
                System.Console.Out.WriteLine("-->configuration details");
                System.Console.Out.WriteLine(cp.ToString());
                if (MakeDistrib)
                {
                    System.Console.Out.WriteLine("-->distribution package details");
                    System.Console.Out.WriteLine(distrib.ToString());
                }
            }
            DateTime stopTime    = new DateTime();
            long     elapsedTime = stopTime.GetTime() - startTime.GetTime();

            System.Console.Out.Printf("Completed processing at %s%n", stopTime);
            System.Console.Out.Printf("Elapsed time: %d seconds%n", (int)(elapsedTime / 1000F));
        }