public virtual List <string> GetInflVars(string separator)

        {
            List <string> inflVars = new List <string>();

            if (lexRecordObjs_ != null)

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

                {
                    LexRecord temp = (LexRecord)lexRecordObjs_[i];

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

                    {
                        InflVar inflVar = (InflVar)inflValues[j];


                        string inflVarDetail = inflVar.GetVar() + separator + inflVar.GetCat() + separator +
                                               inflVar.GetInflection() + separator + inflVar.GetEui() + separator +
                                               inflVar.GetUnInfl() + separator + inflVar.GetCit() + separator +
                                               inflVar.GetType();
                        inflVars.Add(inflVarDetail);
                    }
                }
            }

            return(inflVars);
        }
Esempio n. 2
0
        public static void Main(string[] args)

        {
            string inFile  = "LEXICON";
            string outFile = "inflVars.data";

            if (args.Length == 2)

            {
                inFile  = args[0];
                outFile = args[1];
            }
            else if (args.Length > 0)

            {
                Console.WriteLine("** Usage: java GenerateInflVars <inFile> <outFile>");
                Environment.Exit(0);
            }

            Console.WriteLine("-- inFile: [" + inFile + "]");
            Console.WriteLine("-- outFile: [" + outFile + "]");


            try

            {
                List <InflVar> inflVars          = ToInflVarsApi.GetInflVarsFromTextFile(inFile);
                InflVarComparator <InflVar> comp = new InflVarComparator();
                inflVars.Sort(comp);

                System.IO.StreamWriter outWriter = Files.newBufferedWriter(Paths.get(outFile, new string[0]),
                                                                           Charset.forName("UTF-8"), new OpenOption[0]);


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

                {
                    InflVar inflVar = (InflVar)inflVars[i];
                    if (inflVar.GetUnique() == true)

                    {
                        string outStr = inflVar.GetVar() + "|" + Category.ToValue(inflVar.GetCat()) + "|" +
                                        Inflection.ToValue(inflVar.GetInflection()) + "|" + inflVar.GetEui() + "|" +
                                        inflVar.GetUnInfl() + "|" + inflVar.GetCit();
                        outWriter.Write(outStr);
                        outWriter.WriteLine();
                    }
                }

                outWriter.Close();
            }
            catch (Exception x)

            {
                Console.WriteLine("** ERR@GenerateInflVars( ): " + x.ToString());
            }
        }
Esempio n. 3
0
        public static void Main(string[] args)

        {
            string bat = "{base=bat\nentry=E0012112\n\tcat=noun\n\tvariants=reg\nsignature=vanni\n}";

            string molt =
                "{base=molt\nspelling_variant=moult\nentry=E0040723\n\tcat=noun\n\tvariants=reg\n\tacronym_of=test123\n\tabbreviation_of=test456\n\tacronym_of=test789\nsignature=vanni\n}\n{base=molt\nspelling_variant=moult\nentry=E0040724\n\tcat=verb\n\tvariants=reg\n\tintran\n\ttran=np\n\tnominalization=molting|noun|E0412675\nsignature=vanni\n}";

            if (args.Length == 0)

            {
                try

                {
                    LexRecord        lexRecord;
                    List <LexRecord> lexRecords = ToJavaObjsFromText(molt);
                    for (int i = 0; i < lexRecords.Count; i++)

                    {
                        lexRecord = (LexRecord)lexRecords[i];
                        Console.WriteLine(lexRecord.GetText());

                        Console.WriteLine("---------------------------------");
                    }

                    lexRecord = ToJavaObjFromText(molt);
                    Console.WriteLine(lexRecord.GetText());
                }
                catch (Exception e)

                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                }
            }
            else if (args.Length == 1)

            {
                try

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

                    {
                        Environment.Exit(1);
                    }
                    else

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

                        {
                            LexRecord lexRecord = (LexRecord)lexRecords[i];
                            Console.WriteLine(lexRecord.GetText());
                            Console.WriteLine(lexRecord.GetXml());
                            Console.WriteLine("---------------------------------");
                            InflVarsAndAgreements infls = new InflVarsAndAgreements(lexRecord);

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

                            {
                                InflVar inflVar = (InflVar)inflVars[j];
                                Console.WriteLine("unInfl: " + inflVar.GetUnInfl() + "; infl: " +
                                                  inflVar.GetInflection() + "; var: " + inflVar.GetVar());
                            }
                        }
                    }
                }
                catch (Exception e)

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

            {
                Console.Error.WriteLine("*** Usage: java ToJavaObjApi <filename>");
                Environment.Exit(1);
            }
        }
Esempio n. 4
0
        public static void Main(string[] args)

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

            {
                Console.Error.WriteLine("** Usage: java ToJavaObjectFromTextFile <inFile(Text)> <-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.ToJavaObjsFromTextFile(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);
            }
        }