public void BSBSquared() { Dictionary <string, Dictionary <string, int> > dBSBSquared = new Dictionary <string, Dictionary <string, int> > (); string strPart1 = ""; string strPart2 = ""; StreamWriter swBSBSquared = new StreamWriter(strDataPath + @"bsb_tables_6-7-19-BSBSquared.txt"); //D< foreach (int intRank in slBSB.OrderBy(a => a.Value.strBSort).Select(a => a.Key)) { int intStrong; BSBRecord brecBSBSquared = slBSB [intRank]; brecBSBSquared.CreateDataArray(); //its values have been assigned, so this step can now be taken if (brecBSBSquared.strStrong.Trim().Length > 0) { intStrong = Convert.ToInt32(brecBSBSquared.strStrong.Trim()); } else { intStrong = -1; } for (int intX1 = 0; intX1 < 15; intX1++) { strPart1 = brecBSBSquared.strsRecord[intX1]; if (!dBSBSquared.ContainsKey(strPart1)) { dBSBSquared.Add(strPart1, new Dictionary <string, int>()); } for (int intX2 = 0; intX2 < 15; intX2++) { strPart2 = brecBSBSquared.strsRecord[intX2]; if (!dBSBSquared[strPart1].ContainsKey(strPart2)) { dBSBSquared[strPart1].Add(strPart2, 0); } else { dBSBSquared[strPart1][strPart2]++; } swBSBSquared.WriteLine(strPart1 + " ^ " + strPart2 + " ^ " + dBSBSquared[strPart1][strPart2].ToString()); } //2 } //1 } swBSBSquared.Close(); }
public StringBuilder MakeEnglish() { StringBuilder sbReturn = new StringBuilder(); foreach (int intRecordID in slBSB.Keys.OrderBy(a => a)) { BSBRecord rec = slBSB[intRecordID]; sbReturn.Append(rec.strBSBVersion); sbReturn.Append(' '); } return(sbReturn); }
public void FillslBSB() //Fills slBSB { int intLineCounter = 0; StreamReader srBSB = new StreamReader(strDataPath + @"bsb_tables_6-7-19.csv"); //Read in the file to slBSB while (!srBSB.EndOfStream) { string[] strsLine = srBSB.ReadLine().Split('^'); intLineCounter++; if (intLineCounter > 3 && strsLine[2].Trim() != "") //skip first two lines in this file { BSBRecord bsb = new BSBRecord(); int intHebSort, intGreekSort, intBSort = 0; //strsLine[5] is WLC / Nestle 1904 Base {TR} ⧼RP⧽ (WH) 〈NE〉 [NA] ‹SBL› bsb.strHebSort = strsLine [0].Trim(); //1 bsb.strGreekSort = strsLine [1].Trim(); //0 bsb.strBSort = strsLine [2].Trim(); //1 bsb.strLanguage = strsLine [3].Trim(); //Hebrew bsb.strVerse = strsLine [4].Trim(); //1 bsb.strWLC = strsLine [5].Trim(); //בְּרֵאשִׁ֖ית bsb.strSeperator = strsLine [6].Trim(); //bsb.strTranliteration = Regex.Replace(strsLine [7].Trim().ToLower(), // @"[;,.-·]", @""); //be·re·Shit or bereShit bsb.strTransliteration = strsLine [7].Trim().ToLower(); bsb.strParsing = strsLine [8].Trim(); //Prep-b | N-fs bsb.strStrong = strsLine [9].Trim(); //7225 bsb.strKJVVerse = strsLine [10].Trim(); //genesis 1:1 bsb.strHeading = strsLine [11].Trim(); //The Creation bsb.strBSBVersion = strsLine [12].Trim().ToLower(); //in the beginning bsb.strFootnotes = strsLine [13].Trim(); bsb.strBDBThayers = strsLine [14].Trim(); //1) first, beginning, best, chief <BR> 1a) beginning <BR> 1b) first <BR> 1c) chief <BR> 1d) choice part intHebSort = Convert.ToInt32(bsb.strHebSort); intGreekSort = Convert.ToInt32(bsb.strGreekSort); intBSort = Convert.ToInt32(bsb.strBSort); slBSB.Add(intBSort, bsb); } } srBSB.Close(); }
public void WriteDetailedParseFiles() { Dictionary <string, Dictionary <string, int> > dParses = new Dictionary <string, Dictionary <string, int> >(); Dictionary <string, Dictionary <string, int> > dParsesForeign = new Dictionary <string, Dictionary <string, int> >(); Dictionary <int, Dictionary <string, string> > dEnglishByCount = new Dictionary <int, Dictionary <string, string> >(); Dictionary <int, Dictionary <string, string> > dForeignByCount = new Dictionary <int, Dictionary <string, string> >(); Dictionary <string, Dictionary <int, string> > dEnglishByTag = new Dictionary <string, Dictionary <int, string> >(); Dictionary <string, Dictionary <int, string> > dForeignByTag = new Dictionary <string, Dictionary <int, string> >(); StreamWriter swEnglishByTag = new StreamWriter(strDataPath + @"BSB-EnglishByTags.text"); StreamWriter swForeignByTag = new StreamWriter(strDataPath + @"BSB-ForeignByTags.text"); StreamWriter swEnglishByCount = new StreamWriter(strDataPath + @"BSB-EnglishByCounts.text"); StreamWriter swForeignByCount = new StreamWriter(strDataPath + @"BSB-ForeignByCounts.text"); StreamWriter swEnglish = new StreamWriter(strDataPath + @"BSB-English.text"); StreamWriter swForeign = new StreamWriter(strDataPath + @"BSB-Foreign.text"); Regex rgxOnlyAlphanum = new Regex(@"[a-z0-9 ]"); foreach (int intKey in slBSB.Keys) { BSBRecord rec = slBSB[intKey]; string strEnglish = ""; foreach (Match m in rgxOnlyAlphanum.Matches(rec.strBSBVersion.Trim().ToLower())) { strEnglish += m.Value; } strEnglish = strEnglish.Trim(); if (!dParses.ContainsKey(strEnglish)) { dParses.Add(strEnglish, new Dictionary <string, int>()); } if (rec.strParsing.Contains("|")) { foreach (string strParsePart in rec.strParsing.Split("|".ToCharArray())) { if (!dParses[strEnglish].ContainsKey(strParsePart.Trim().ToLower())) { dParses[strEnglish].Add(strParsePart.Trim().ToLower(), 1); } else { dParses[strEnglish][strParsePart.Trim().ToLower()]++; } } } else { if (!dParses[strEnglish].ContainsKey(rec.strParsing.Trim().ToLower())) { dParses[strEnglish].Add(rec.strParsing.Trim().ToLower(), 1); } else { dParses[strEnglish][rec.strParsing.Trim().ToLower()]++; } } //foreign if (!dParsesForeign.ContainsKey(rec.strTransliteration.Trim().ToLower())) { dParsesForeign.Add(rec.strTransliteration.Trim().ToLower(), new Dictionary <string, int>()); } if (rec.strParsing.Contains("|")) { foreach (string strParsePart in rec.strParsing.Split("|".ToCharArray())) { if (!dParsesForeign[rec.strTransliteration.Trim().ToLower()].ContainsKey(strParsePart.Trim().ToLower())) { dParsesForeign[rec.strTransliteration.Trim().ToLower()].Add(strParsePart.Trim().ToLower(), 1); } else { dParsesForeign[rec.strTransliteration.Trim().ToLower()][strParsePart.Trim().ToLower()]++; } } } else { if (!dParsesForeign[rec.strTransliteration.Trim().ToLower()].ContainsKey(rec.strParsing.Trim().ToLower())) { dParsesForeign[rec.strTransliteration.Trim().ToLower()].Add(rec.strParsing.Trim().ToLower(), 1); } else { dParsesForeign[rec.strTransliteration.Trim().ToLower()][rec.strParsing.Trim().ToLower()]++; } } } foreach (string strKey in dParses.Keys.OrderBy(a => a)) { foreach (string strKey2 in dParses[strKey].Keys.OrderBy(b => b)) { swEnglish.WriteLine(strKey + " ^ " + strKey2 + " ^ " + dParses[strKey][strKey2]); if (!dEnglishByCount.ContainsKey(dParses[strKey][strKey2])) { dEnglishByCount.Add(dParses[strKey][strKey2], new Dictionary <string, string>()); } if (!dEnglishByCount[dParses[strKey][strKey2]].ContainsKey(strKey2)) { dEnglishByCount[dParses[strKey][strKey2]].Add(strKey2, strKey); } if (!dEnglishByTag.ContainsKey(strKey2)) { dEnglishByTag.Add(strKey2, new Dictionary <int, string>()); } if (!dEnglishByTag[strKey2].ContainsKey(dParses[strKey][strKey2])) { dEnglishByTag[strKey2].Add(dParses[strKey][strKey2], strKey); } } } foreach (string strKey in dParsesForeign.Keys.OrderBy(a => a)) { foreach (string strKey2 in dParsesForeign[strKey].Keys.OrderBy(b => b)) { swForeign.WriteLine(strKey + " ^ " + strKey2 + " ^ " + dParsesForeign[strKey][strKey2]); if (!dForeignByCount.ContainsKey(dParsesForeign[strKey][strKey2])) { dForeignByCount.Add(dParsesForeign[strKey][strKey2], new Dictionary <string, string>()); } if (!dForeignByCount[dParsesForeign[strKey][strKey2]].ContainsKey(strKey2)) { dForeignByCount[dParsesForeign[strKey][strKey2]].Add(strKey2, strKey); } if (!dForeignByTag.ContainsKey(strKey2)) { dForeignByTag.Add(strKey2, new Dictionary <int, string>()); } if (!dForeignByTag[strKey2].ContainsKey(dParsesForeign[strKey][strKey2])) { dForeignByTag[strKey2].Add(dParsesForeign[strKey][strKey2], strKey); } } } foreach (int intKey in dEnglishByCount.Keys.OrderByDescending(a => a)) { foreach (string strKey2 in dEnglishByCount[intKey].Keys.OrderBy(b => b)) { swEnglishByCount.WriteLine(intKey.ToString() + " ^ " + strKey2 + " ^ " + dEnglishByCount[intKey][strKey2]); } } foreach (int intKey in dForeignByCount.Keys.OrderByDescending(a => a)) { foreach (string strKey2 in dForeignByCount[intKey].Keys.OrderBy(b => b)) { swForeignByCount.WriteLine(intKey + " ^ " + strKey2 + " ^ " + dForeignByCount[intKey][strKey2]); } } foreach (string strKey in dEnglishByTag.Keys.OrderBy(a => a)) { foreach (int intKey2 in dEnglishByTag[strKey].Keys.OrderByDescending(b => b)) { swEnglishByTag.WriteLine(strKey.ToString() + " ^ " + intKey2 + " ^ " + dEnglishByTag[strKey][intKey2]); } } foreach (string strKey in dForeignByTag.Keys.OrderBy(a => a)) { foreach (int intKey2 in dForeignByTag[strKey].Keys.OrderByDescending(b => b)) { swForeignByTag.WriteLine(strKey + " ^ " + intKey2 + " ^ " + dForeignByTag[strKey][intKey2]); } } swForeignByCount.Close(); swEnglishByCount.Close(); swForeign.Close(); swEnglish.Close(); }
public void ReadBSBInterlinear() { if (File.Exists(strDataPath + @"bsb_tables_6-7-19.csv")) { //load bsbrecords StreamReader srBSBRecords = new StreamReader(strDataPath + @"bsb_tables_6-7-19.csv"); //Data File Header Management BSBRecord brecTest = new BSBRecord(); bool bHeader = false; brecTest.FromRecord(srBSBRecords.ReadLine()); if (brecTest.strBSBVersion == "BSB Version") { bHeader = true; } srBSBRecords.Close(); srBSBRecords = new StreamReader(strDataPath + @"bsb_tables_6-7-19.csv"); if (bHeader) { srBSBRecords.ReadLine(); } //END Header while (!srBSBRecords.EndOfStream) { BSBRecord brecAdd = new BSBRecord(); brecAdd.FromRecord(srBSBRecords.ReadLine()); slBSB.Add(slBSB.Count() + 1, brecAdd); } } else { FillslBSB(); WriteBSBRecords(); //writes slBSB to file } foreach (int intBSort in slBSB.Keys.OrderBy(a => a)) { if (intBSort > 0) { slBSBForeignLanguageKey.Add(intBSort, slBSB[intBSort]); } } if (File.Exists(strDataPath + @"bsb_tables_6-7-19-UnifiedChunks-Hebrew.txt")) { //Load Hebrew StreamReader srHebrew = new StreamReader(strDataPath + @"bsb_tables_6-7-19-UnifiedChunks-Hebrew.txt"); while (!srHebrew.EndOfStream) { string[] strsLine = srHebrew.ReadLine().Split('^'); // if (!dBSBChunksEH.ContainsKey(strsLine [0].Trim())) { dBSBChunksEH.Add(strsLine [0].Trim(), new List <string> ()); } dBSBChunksEH [strsLine [0].Trim()].Add(strsLine [1].Trim()); } } else { StreamWriter swUnifiedChunksHebrew = new StreamWriter(strDataPath + @"bsb_tables_6-7-19-UnifiedChunks-Hebrew.txt"); StreamWriter swParsing = new StreamWriter(strDataPath + @"bsb_tables_6-7-19-Parsing.txt"); CreateHebrewOrderedByEnglish(); WriteParsing(ref swParsing); //Parse creation hitches a loop ride with CreateOrderingByEnglishAndHebrew WriteUnifiedChunksHebrew(ref swUnifiedChunksHebrew); } if (File.Exists(strDataPath + @"bsb_tables_6-7-19-UnifiedChunks-Greek.txt")) { //load Greek StreamReader srGreek = new StreamReader(strDataPath + @"bsb_tables_6-7-19-UnifiedChunks-Greek.txt"); while (!srGreek.EndOfStream) { string[] strsLine = srGreek.ReadLine().Split('^'); // if (!dBSBChunksEG.ContainsKey(strsLine [1].Trim())) { dBSBChunksEG.Add(strsLine [1].Trim(), new List <string> ()); } dBSBChunksEG [strsLine [1].Trim()].Add(strsLine [0].Trim()); } } else { StreamWriter swUnifiedChunksGreek = new StreamWriter(strDataPath + @"bsb_tables_6-7-19-UnifiedChunks-Greek.txt"); CreateGreekOrderedByEnglish(); WriteUnifiedChunksGreek(ref swUnifiedChunksGreek); } if (File.Exists(strDataPath + @"bsb_tables_6-7-19-SemanticParts.txt")) { //load SemanticParts StreamReader srSemanticParts = new StreamReader(strDataPath + @"bsb_tables_6-7-19-SemanticParts.txt"); while (!srSemanticParts.EndOfStream) { string[] strsLine = srSemanticParts.ReadLine().Split('^'); if (!dSemanticParts.ContainsKey(strsLine [0].Trim())) { dSemanticParts.Add(strsLine [0].Trim(), new List <string> ()); } dSemanticParts [strsLine [0].Trim()].Add(strsLine [1].Trim()); if (!dSemanticPartsReversed.ContainsKey(strsLine [0].Trim())) { dSemanticPartsReversed.Add(strsLine [0].Trim(), new List <string> ()); } dSemanticPartsReversed [strsLine [0].Trim()].Add(strsLine [1].Trim()); } } else { CreateSemanticTagParts(); WriteSemanticTags(); } //BSBSquared (); //Experimental }