Exemple #1
0
        /// <param name="args"/>
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Error.Printf("Usage: java %s tree_file%n", typeof(SplitMaker).FullName);
                System.Environment.Exit(-1);
            }
            ITreebankLanguagePack tlp = new HebrewTreebankLanguagePack();
            string inputFile          = args[0];
            File   treeFile           = new File(inputFile);

            try
            {
                ITreeReaderFactory trf     = new HebrewTreeReaderFactory();
                BufferedReader     br      = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), tlp.GetEncoding()));
                ITreeReader        tr      = trf.NewTreeReader(br);
                PrintWriter        pwDev   = new PrintWriter(new TextWriter(new FileOutputStream(inputFile + ".clean.dev"), false, tlp.GetEncoding()));
                PrintWriter        pwTrain = new PrintWriter(new TextWriter(new FileOutputStream(inputFile + ".clean.train"), false, tlp.GetEncoding()));
                PrintWriter        pwTest  = new PrintWriter(new TextWriter(new FileOutputStream(inputFile + ".clean.test"), false, tlp.GetEncoding()));
                int numTrees = 0;
                for (Tree t; ((t = tr.ReadTree()) != null); numTrees++)
                {
                    if (numTrees < 483)
                    {
                        pwDev.Println(t.ToString());
                    }
                    else
                    {
                        if (numTrees >= 483 && numTrees < 5724)
                        {
                            pwTrain.Println(t.ToString());
                        }
                        else
                        {
                            pwTest.Println(t.ToString());
                        }
                    }
                }
                tr.Close();
                pwDev.Close();
                pwTrain.Close();
                pwTest.Close();
                System.Console.Error.Printf("Processed %d trees.%n", numTrees);
            }
            catch (UnsupportedEncodingException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            catch (FileNotFoundException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            catch (IOException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }
        /// <param name="args"/>
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.Error.Printf("Usage: java %s tree_file > trees%n", typeof(HebrewTreeReaderFactory).FullName);
                System.Environment.Exit(-1);
            }
            ITreebankLanguagePack tlp = new HebrewTreebankLanguagePack();
            File treeFile             = new File(args[0]);

            try
            {
                ITreeReaderFactory trf = new HebrewTreeReaderFactory();
                BufferedReader     br  = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), tlp.GetEncoding()));
                ITreeReader        tr  = trf.NewTreeReader(br);
                int numTrees           = 0;
                for (Tree t; ((t = tr.ReadTree()) != null); numTrees++)
                {
                    System.Console.Out.WriteLine(t.ToString());
                }
                tr.Close();
                System.Console.Error.Printf("Processed %d trees.%n", numTrees);
            }
            catch (UnsupportedEncodingException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            catch (FileNotFoundException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            catch (IOException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }