public static void CheckFromFile(string inFile, string outFile, bool verbose,
                                         Dictionary <string, HashSet <string> > dupRecExpList, HashSet <string> notBaseFormSet)

        {
            try

            {
                List <LexRecord>       lexRecords = ToJavaObjApi.ToJavaObjsFromTextFile(inFile);
                System.IO.StreamWriter @out       = new System.IO.StreamWriter(
                    new System.IO.FileStream(outFile, System.IO.FileMode.Create, System.IO.FileAccess.Write),
                    Encoding.UTF8);

                System.IO.StreamWriter dupOut = new System.IO.StreamWriter(
                    new System.IO.FileStream(outFile + ".dupRec", System.IO.FileMode.Create,
                                             System.IO.FileAccess.Write), Encoding.UTF8);


                CheckLexRecords(lexRecords, @out, dupOut, verbose, dupRecExpList, notBaseFormSet);

                @out.Close();
                dupOut.Close();
            }
            catch (Exception e)

            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
        public virtual void SetText(string text)

        {
            text_ = text;

            try

            {
                lexRecordObjs_ = ToJavaObjApi.ToJavaObjsFromText(text);
            }
            catch (Exception e)

            {
                Console.WriteLine("** Error: " + e.Message);
            }
        }
        public static void CheckLexRecordsFromFile(string inFile, string outFile, bool verbose,
                                                   HashSet <string> irregExpEuiList)

        {
            try

            {
                List <LexRecord>       lexRecords = ToJavaObjApi.ToJavaObjsFromTextFile(inFile);
                System.IO.StreamWriter @out       = new System.IO.StreamWriter(
                    new System.IO.FileStream(outFile, System.IO.FileMode.Create, System.IO.FileAccess.Write),
                    Encoding.UTF8);


                CheckLexRecords(lexRecords, @out, verbose, irregExpEuiList);
                @out.Close();
            }
            catch (Exception e)

            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
Exemple #4
0
        public static void Main(string[] args)

        {
            if ((args.Length == 0) || (args.Length > 2))

            {
                Console.Error.WriteLine("** Usage: java ToJavaObjectFromXmlFile <inFile(Xml)> <-i>");
                Console.Error.WriteLine("");
                Console.Error.WriteLine("Options:");
                Console.Error.WriteLine("  -i: generate inflection vars");
                Environment.Exit(1);
            }

            bool inflVarFlag = false;

            for (int i = 0; i < args.Length; i++)

            {
                if (args[i].Equals("-i"))

                {
                    inflVarFlag = true;
                    break;
                }
            }

            try

            {
                List <LexRecord> lexRecords = ToJavaObjApi.ToJavaObjsFromXmlFile(args[0]);
                if (lexRecords.Count <= 0)

                {
                    Environment.Exit(1);
                }
                else

                {
                    for (int i = 0; i < lexRecords.Count; i++)

                    {
                        LexRecord lexRecord = (LexRecord)lexRecords[i];
                        Console.Write(lexRecord.GetText());
                        if (inflVarFlag == true)

                        {
                            Console.WriteLine("---------- Inflection Vars ----------");

                            List <InflVar> inflVars = lexRecord.GetInflVarsAndAgreements().GetInflValues();
                            for (int j = 0; j < inflVars.Count; j++)

                            {
                                InflVar inflVar = (InflVar)inflVars[j];
                                Console.WriteLine(inflVar.GetVar() + "|" + Category.ToValue(inflVar.GetCat()) + "|" +
                                                  Inflection.ToValue(inflVar.GetInflection()) + "|" + inflVar.GetEui() +
                                                  "|" + inflVar.GetUnInfl() + "|" + inflVar.GetCit());
                            }
                        }
                    }
                }
            }
            catch (Exception e)

            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
        public static void Main(string[] args)

        {
            string inFile          = "LEXICON";
            string prepositionFile = "../data/Files/prepositions.data";
            bool   verbose         = false;

            if (args.Length == 1)

            {
                inFile = args[0];
            }
            else if (args.Length == 2)

            {
                inFile = args[0];
                if (args[1].Equals("-v") == true)

                {
                    verbose = true;
                }
            }
            else if (args.Length == 3)

            {
                inFile = args[0];
                if (args[1].Equals("-v") == true)

                {
                    verbose = true;
                }

                prepositionFile = args[2];
            }
            else if (args.Length >= 0)

            {
                Console.Error.WriteLine(
                    "** Usage: java ValidateSyntaxFromTextFile <inFile> <verbose> <prepositionFile>");
                Environment.Exit(1);
            }

            int recNum = 0;

            try

            {
                recNum = ToJavaObjApi.CheckRecordsFromTextFile(inFile, prepositionFile);
            }
            catch (Exception e)

            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            if (verbose == true)

            {
                Console.WriteLine("===== ValidateSyntaxFromTextFile( ) ======");
                Console.WriteLine("-- inFile: [" + inFile + "]");
                Console.WriteLine("-- prepositionsFile: [" + Lib.GlobalVars.GetPrepositionFile() + "]");
            }

            if (recNum > 0)

            {
                Console.WriteLine("-- inFile(" + inFile + "): " + recNum + " records checked. No error found.");
            }
        }