public static List <InflVar> GetInflVarsFromTextFile(string inFile) { CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); List <InflVar> inflVars = new List <InflVar>(); try { System.IO.StreamReader inReader = new System.IO.StreamReader( new System.IO.FileStream(inFile, System.IO.FileMode.Open, System.IO.FileAccess.Read), Encoding.UTF8); while (lineObject != null) { if (lineObject.IsGoToNext() == true) { lineObject.SetLine(inReader.ReadLine()); lineObject.IncreaseLineNum(); } if (lineObject.GetLine() == null) { break; } bool flag = CheckGrammer.Check(lineObject, true, st, catSt, false); if ((st.GetCurState() == 10) && (flag == true)) { InflVarsAndAgreements infls = new InflVarsAndAgreements(CheckGrammer.GetLexRecord()); inflVars.AddRange(infls.GetInflValues()); } } inReader.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } return(inflVars); }
public static void Main(string[] args) { LexRecord lexRec = new LexRecord(); lexRec.SetBase("123"); lexRec.SetCat("noun"); lexRec.GetCatEntry().GetNounEntry().AddVariant("irreg|123||"); lexRec.GetCatEntry().GetNounEntry().AddVariant("group(irreg|123|222|)"); Console.WriteLine("----------------"); Console.WriteLine(lexRec.GetText()); Console.WriteLine("----------------"); InflVarsAndAgreements inflVars = lexRec.GetInflVarsAndAgreements(); List <InflVar> inflValues = inflVars.GetInflValues(); for (int i = 0; i < inflValues.Count; i++) { InflVar inflectionVar = inflValues[i]; Console.WriteLine(inflectionVar.GetVar() + "|" + inflectionVar.GetCat() + "|" + inflectionVar.GetInflection() + "|" + inflectionVar.GetUnInfl() + "|" + inflectionVar.GetCit() + "|" + inflectionVar.GetType()); } }
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); } }