Ejemplo n.º 1
0
 /// <summary>
 /// Initialize variables
 /// </summary>
 public CreateIndex()
 {
     currentBook    = String.Empty;
     currentChapter = String.Empty;
     currentVerse   = String.Empty;
     verseID        = String.Empty;
     word           = new StringBuilder();
     bookInfo       = new BibleBookInfo();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize this instance of ExtractSearchText
 /// </summary>
 public ExtractSearchText()
 {
     currentBook         = String.Empty;
     currentChapter      = String.Empty;
     currentVerse        = String.Empty;
     currentPlace        = String.Empty;
     inVerse             = false;
     inPsalmTitle        = false;
     verseEndedWithSpace = false;
     bookInfo            = new BibleBookInfo();
     LongestWordLength   = 0;
 }
Ejemplo n.º 3
0
 public VersePointer(
     BibleBookInfo bookInfo,
     string moduleShortName,
     string originalVerseName,
     VerseNumber verseNumber,
     VerseNumber?topVerseNumber = null)
     : base(bookInfo != null ? bookInfo.Index : 0, verseNumber, topVerseNumber)
 {
     Book              = bookInfo;
     ModuleShortName   = moduleShortName;
     OriginalVerseName = originalVerseName;
     SubVerses         = new VersesListInfo <ModuleVersePointer>();
 }
Ejemplo n.º 4
0
        public void Parse(string usfxPath)
        {
            BibleBookInfo bookInfo = new BibleBookInfo();

            bookInfo.ReadUsfxVernacularNames(usfxPath);
            foreach (BibleBookRecord br in bookInfo.bookArray)
            {
                if ((br != null) && (!String.IsNullOrEmpty(br.tla)) && (!String.IsNullOrEmpty(br.vernacularAbbreviation) && (!String.IsNullOrEmpty(br.vernacularShortName))))
                {
                    BookIds.Add(br.tla);
                    VernacularNames[br.tla]        = br.vernacularShortName;
                    ReferenceAbbreviations[br.tla] = br.vernacularAbbreviation;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Reads the \id line to get the standard abbreviation of this file to figure out what
        /// a good name for its standardized file name might be.
        /// </summary>
        /// <param name="pathName">Full path to the file to read the \id line from.</param>
        /// <returns>Sort order plus 3-letter abbreviation of the Bible book (or front/back matter), upper case,
        /// unless the file lacks an \id line, in which case in returns and empty string.</returns>
        public string MakeUpUsfmFileName(string pathName, out string id)
        {
            if (bkInfo == null)
            {
                bkInfo = new WordSend.BibleBookInfo();
            }
            // Use the ID line.
            string result = "";

            id = "";
            string       line;
            string       chap = "";
            StreamReader sr   = new StreamReader(pathName);

            while ((!sr.EndOfStream) && (result.Length < 1))
            {
                line = sr.ReadLine();
                if (line.StartsWith(@"\id ") && (line.Length > 6))
                {
                    id = result = line.Substring(4, 3).ToUpper(System.Globalization.CultureInfo.InvariantCulture);
                }
                else if ((line.StartsWith(@"\c ")) && (line.Length > 3))
                {
                    chap = line.Substring(3).Trim();
                    int pos = chap.IndexOf(' ');
                    if (pos >= 0)
                    {
                        chap = chap.Substring(0, pos);
                    }
                }
            }
            sr.Close();
            if (chap == "1")
            {
                chap = "";
            }
            if (result.Length > 0)
            {
                result = bkInfo.Order(result).ToString("D2") + "-" + result + chap;
            }
            return(result);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            BibleBookInfo   bkInfo = new BibleBookInfo();
            StreamReader    sr;
            StreamWriter    sw = null;
            string          line, bookCode, chapter, verse, verseText, s;
            string          bookID                   = String.Empty;
            string          lastBook                 = String.Empty;
            string          lastChapter              = String.Empty;
            string          testament                = "o";
            string          inFileName               = "luo.txt";
            string          findStrongMorph          = @"(\w*) <(\d*)> \((\d*)\)";
            string          replaceStrongMorphOT     = @"\zw \+zws H$2\+zws*\+zwm strongMorph:TH$3\+zwm*\zw*$1\zx \zx*";
            string          replaceStrongMorphNT     = @"\zw \+zws G$2\+zws*\+zwm strongMorph:TG$3\+zwm*\zw*$1\zx \zx*";
            string          findStrongOnly           = @"(\w*) <(\d*)>";
            string          replaceStrongOnlyOT      = @"\zw \+zws H$2\+zws*\zw*$1\zx \zx*";
            string          replaceStrongOnlyNT      = @"\zw \+zws G$2\+zws*\zw*$1\zx \zx*";
            string          findMorphOnly            = @"(\w*) \((\d*)\)";
            string          replaceMorphOnlyOT       = @"\zw \+zwm strongMorph:TH$2\+zwm*\zw*$1\zx \zx*";
            string          replaceMorphOnlyNT       = @"\zw \+zwm strongMorph:TG$2\+zwm*\zw*$1\zx \zx*";
            string          findBackwardsStrong      = @"<(\d*)> (\w*)";
            string          replaceBackwardsStrongOT = @"\zw \+zws H$1\+zws*\zw*$2\zx \zx*";
            string          replaceBackwardsStrongNT = @"\zw \+zws G$1\+zws*\zw*$2\zx \zx*";
            string          findStrayStrongs         = @"<\d*>";
            string          replaceStrayStrongs      = String.Empty;
            string          findFootNoteKeyWords     = @"\{(.*)<i>(.*)</i>(.*)\}";
            string          replaceFootNoteKeyWords  = @"{$1\fk $2\ft $3}";
            string          findFootNote             = @"\ { \w\w\w (\d*:\d*)(.*) \}";
            string          replaceFootNote          = @"\f + \fr $1 \ft $2\f*";
            BibleBookRecord br;

            char[]    tabSeparator = new char[] { '\t' };
            Hashtable bkcodes = new Hashtable();
            int       i, j;

            try
            {
                // Get the name of our input file
                if (args.Length > 0)
                {
                    inFileName = args[0];
                }

                // Read in book text and write simple USFM
                sr   = new StreamReader(inFileName);
                line = sr.ReadLine();
                while (line != null)
                {
                    if ((line.Length > 8) && !line.StartsWith("#"))
                    {
                        bookCode  = line.Substring(0, 3);
                        i         = line.IndexOf(':');
                        chapter   = line.Substring(4, i - 4);
                        j         = line.IndexOf(' ', i + 1);
                        verse     = line.Substring(i + 1, j - i - 1);
                        verseText = line.Substring(j + 1);
                        if (bookCode != lastBook)
                        {
                            if (sw != null)
                            {
                                sw.Close();
                            }
                            bookID = bkInfo.tlaFromBW(bookCode);
                            br     = bkInfo.BkRec(bookID);
                            if (br != null)
                            {
                                testament = bkInfo.BkRec(bookID).testament;
                            }
                            sw = new StreamWriter(bookID + ".sfm", false, Encoding.UTF8);
                            sw.WriteLine("\\id {0}", bookID);
                            lastBook    = bookCode;
                            lastChapter = String.Empty;
                            Console.Write("{0} ", bookID);
                        }
                        if (testament == "o")
                        {
                            verseText = Regex.Replace(verseText, findStrongMorph, replaceStrongMorphOT);
                            verseText = Regex.Replace(verseText, findStrongOnly, replaceStrongOnlyOT);
                            verseText = Regex.Replace(verseText, findMorphOnly, replaceMorphOnlyOT);
                            verseText = Regex.Replace(verseText, findBackwardsStrong, replaceBackwardsStrongOT);
                        }
                        else if (testament == "n")
                        {
                            verseText = Regex.Replace(verseText, findStrongMorph, replaceStrongMorphNT);
                            verseText = Regex.Replace(verseText, findStrongOnly, replaceStrongOnlyNT);
                            verseText = Regex.Replace(verseText, findMorphOnly, replaceMorphOnlyNT);
                            verseText = Regex.Replace(verseText, findBackwardsStrong, replaceBackwardsStrongNT);
                        }
                        verseText = Regex.Replace(verseText, findStrayStrongs, replaceStrayStrongs);
                        do
                        {
                            s         = verseText;
                            verseText = Regex.Replace(verseText, findFootNoteKeyWords, replaceFootNoteKeyWords);
                        }while (s != verseText);
                        verseText = Regex.Replace(verseText, findFootNote, replaceFootNote);
                        verseText = Regex.Replace(verseText, @"<i>", @"\it ");
                        verseText = Regex.Replace(verseText, @"</i>", @" \it*");
                        verseText = Regex.Replace(verseText, @"\(\d*:\d*\)", String.Empty); // Alternate versification markers-- ignore for now

                        if (chapter != lastChapter)
                        {
                            sw.WriteLine("\\c {0}", chapter);
                            lastChapter = chapter;
                            if (bookID != "PSA")
                            {
                                sw.WriteLine("\\p");
                            }
                        }
                        if (bookID == "PSA")
                        {
                            sw.WriteLine("\\q1");
                        }
                        sw.WriteLine("\\v {0} {1}", verse, verseText);
                    }
                    line = sr.ReadLine();
                }
                Console.WriteLine();
                sw.Close();
                sr.Close();
                Console.WriteLine("bww2sfm done");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 7
0
 public ChapterPointer(BibleBookInfo bookInfo, string moduleShortName, int chapter)
     : base(bookInfo, moduleShortName, string.Empty, new VerseNumber(chapter))
 {
 }