public static ApiOutput ToXmlFromText(string text) { CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); StringBuilder xmlOut = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); xmlOut.Append("<lexRecords>\n"); int recordNum = 0; string unixText = text.Replace("\r\n", "\n"); string[] buf = unixText.Split('\n').ToList().Where(x => x != "").ToArray(); foreach (string line in buf) { if (lineObject.IsGoToNext() == true) { lineObject.SetLine(line); lineObject.IncreaseLineNum(); } recordNum = CheckLine(st, catSt, lineObject, xmlOut, recordNum); } xmlOut.Append("</lexRecords>\n"); ApiOutput apiOutput = new ApiOutput(xmlOut.ToString(), recordNum); return(apiOutput); }
public static List <Agreement> GetAgreementsFromTextFile(string inFile) { CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); List <Agreement> agreements = new List <Agreement>(); 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 agrs = new InflVarsAndAgreements(CheckGrammer.GetLexRecord()); agreements.AddRange(agrs.GetAgreementValues()); } } inReader.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } return(agreements); }
public static ApiOutput ToXmlFromTextFile(string inFile) { CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); StringBuilder xmlOut = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); xmlOut.Append("<lexRecords>\n"); int recordNum = 0; 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; } recordNum = CheckLine(st, catSt, lineObject, xmlOut, recordNum); } inReader.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } xmlOut.Append("</lexRecords>\n"); ApiOutput apiOutput = new ApiOutput(xmlOut.ToString(), recordNum); return(apiOutput); }
public static List <LexRecord> ToJavaObjsFromTextFile(string inFile) { CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); int recordNum = 0; List <LexRecord> lexRecords = new List <LexRecord>(); 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; } recordNum = CheckLine(st, catSt, lineObject, lexRecords, recordNum); } inReader.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } return(lexRecords); }
public static bool CheckRecordText(string text) { ErrMsg.ResetErrMsg(); CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); string unixText = text.Replace("\r\n", "\n"); List <LexRecord> lexRecords = new List <LexRecord>(); if (!string.IsNullOrEmpty(unixText)) { string[] buf = unixText.Split('\n').ToList().Where(x => x != "").ToArray(); int i = -1; while (lineObject != null) { if (lineObject.IsGoToNext() == true) { i += 1; if (i >= buf.Length) { break; } string line = buf[i]; lineObject.SetLine(line); lineObject.IncreaseLineNum(); } else if (!CheckLine2(st, catSt, lineObject)) { return(false); } } } return(true); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static int CheckRecordsFromTextFile(String inFile, String prepositionFile) throws Exception public static int CheckRecordsFromTextFile(string inFile, string prepositionFile) { GlobalVars.SetPrepositionFile(prepositionFile); lexRecNum_ = 0; CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); 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) { string line = inReader.ReadLine(); if (!ReferenceEquals(line, null)) { lineObject.SetLine(line); lineObject.IncreaseLineNum(); } } else if (!CheckLine2(st, catSt, lineObject)) { return(-1); } } inReader.Close(); return(lexRecNum_); }
public static List <LexRecord> ToJavaObjsFromText(string text) { CheckSt st = new CheckSt(); CheckSt catSt = new CheckSt(40); LineObject lineObject = new LineObject(); string unixText = text.Replace("\r\n", "\n").Trim(); List <LexRecord> lexRecords = new List <LexRecord>(); if (!string.IsNullOrEmpty(unixText)) { string[] buf = unixText.Split('\n').ToList().Where(x => x != "").ToArray(); int i = -1; while (lineObject != null) { if (lineObject.IsGoToNext() == true) { i += 1; if (i >= buf.Length) { break; } string line = buf[i]; lineObject.SetLine(line); lineObject.IncreaseLineNum(); } CheckLine(st, catSt, lineObject, lexRecords); } } return(lexRecords); }