Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in verse tag for B\C\V format #127

Open
GeoDirk opened this issue May 25, 2021 · 2 comments
Open

Add in verse tag for B\C\V format #127

GeoDirk opened this issue May 25, 2021 · 2 comments

Comments

@GeoDirk
Copy link
Contributor

GeoDirk commented May 25, 2021

It is commonly used in the Natural Language Processing world to refer to verses by their Book\Chapter\Verse format. This looks like: 01001001 format (string) with the first two characters being the book ID number, the next three characters being the chapter number, and the final three numbers being the verse number.

Ideally, this tag would be an attribute of the VMarker that is generated during parsing so that user can drill down to the verse quickly.

The book numbers can be extracted from this list (I have no idea why book 40 is skipped from the official list):

// initialize the list
List<Book> books = new List<Book>
{
    new Book{BookID = "01", BookNameShort = "GEN", USFM_Num = 1},
    new Book{BookID = "02", BookNameShort = "EXO", USFM_Num = 2},
    new Book{BookID = "03", BookNameShort = "LEV", USFM_Num = 3},
    new Book{BookID = "04", BookNameShort = "NUM", USFM_Num = 4},
    new Book{BookID = "05", BookNameShort = "DEU", USFM_Num = 5},
    new Book{BookID = "06", BookNameShort = "JOS", USFM_Num = 6},
    new Book{BookID = "07", BookNameShort = "JDG", USFM_Num = 7},
    new Book{BookID = "08", BookNameShort = "RUT", USFM_Num = 8},
    new Book{BookID = "09", BookNameShort = "1SA", USFM_Num = 9},
    new Book{BookID = "10", BookNameShort = "2SA", USFM_Num = 10},
    new Book{BookID = "11", BookNameShort = "1KI", USFM_Num = 11},
    new Book{BookID = "12", BookNameShort = "2KI", USFM_Num = 12},
    new Book{BookID = "13", BookNameShort = "1CH", USFM_Num = 13},
    new Book{BookID = "14", BookNameShort = "2CH", USFM_Num = 14},
    new Book{BookID = "15", BookNameShort = "EZR", USFM_Num = 15},
    new Book{BookID = "16", BookNameShort = "NEH", USFM_Num = 16},
    new Book{BookID = "17", BookNameShort = "EST", USFM_Num = 17},
    new Book{BookID = "18", BookNameShort = "JOB", USFM_Num = 18},
    new Book{BookID = "19", BookNameShort = "PSA", USFM_Num = 19},
    new Book{BookID = "20", BookNameShort = "PRO", USFM_Num = 20},
    new Book{BookID = "21", BookNameShort = "ECC", USFM_Num = 21},
    new Book{BookID = "22", BookNameShort = "SNG", USFM_Num = 22},
    new Book{BookID = "23", BookNameShort = "ISA", USFM_Num = 23},
    new Book{BookID = "24", BookNameShort = "JER", USFM_Num = 24},
    new Book{BookID = "25", BookNameShort = "LAM", USFM_Num = 25},
    new Book{BookID = "26", BookNameShort = "EZK", USFM_Num = 26},
    new Book{BookID = "27", BookNameShort = "DAN", USFM_Num = 27},
    new Book{BookID = "28", BookNameShort = "HOS", USFM_Num = 28},
    new Book{BookID = "29", BookNameShort = "JOL", USFM_Num = 29},
    new Book{BookID = "30", BookNameShort = "AMO", USFM_Num = 30},
    new Book{BookID = "31", BookNameShort = "OBA", USFM_Num = 31},
    new Book{BookID = "32", BookNameShort = "JON", USFM_Num = 32},
    new Book{BookID = "33", BookNameShort = "MIC", USFM_Num = 33},
    new Book{BookID = "34", BookNameShort = "NAM", USFM_Num = 34},
    new Book{BookID = "35", BookNameShort = "HAB", USFM_Num = 35},
    new Book{BookID = "36", BookNameShort = "ZEP", USFM_Num = 36},
    new Book{BookID = "37", BookNameShort = "HAG", USFM_Num = 37},
    new Book{BookID = "38", BookNameShort = "ZEC", USFM_Num = 38},
    new Book{BookID = "39", BookNameShort = "MAL", USFM_Num = 39},
    new Book{BookID = "41", BookNameShort = "MAT", USFM_Num = 41},
    new Book{BookID = "42", BookNameShort = "MRK", USFM_Num = 42},
    new Book{BookID = "43", BookNameShort = "LUK", USFM_Num = 43},
    new Book{BookID = "44", BookNameShort = "JHN", USFM_Num = 44},
    new Book{BookID = "45", BookNameShort = "ACT", USFM_Num = 45},
    new Book{BookID = "46", BookNameShort = "ROM", USFM_Num = 46},
    new Book{BookID = "47", BookNameShort = "1CO", USFM_Num = 47},
    new Book{BookID = "48", BookNameShort = "2CO", USFM_Num = 48},
    new Book{BookID = "49", BookNameShort = "GAL", USFM_Num = 49},
    new Book{BookID = "50", BookNameShort = "EPH", USFM_Num = 50},
    new Book{BookID = "51", BookNameShort = "PHP", USFM_Num = 51},
    new Book{BookID = "52", BookNameShort = "COL", USFM_Num = 52},
    new Book{BookID = "53", BookNameShort = "1TH", USFM_Num = 53},
    new Book{BookID = "54", BookNameShort = "2TH", USFM_Num = 54},
    new Book{BookID = "55", BookNameShort = "1TI", USFM_Num = 55},
    new Book{BookID = "56", BookNameShort = "2TI", USFM_Num = 56},
    new Book{BookID = "57", BookNameShort = "TIT", USFM_Num = 57},
    new Book{BookID = "58", BookNameShort = "PHM", USFM_Num = 58},
    new Book{BookID = "59", BookNameShort = "HEB", USFM_Num = 59},
    new Book{BookID = "60", BookNameShort = "JAS", USFM_Num = 60},
    new Book{BookID = "61", BookNameShort = "1PE", USFM_Num = 61},
    new Book{BookID = "62", BookNameShort = "2PE", USFM_Num = 62},
    new Book{BookID = "63", BookNameShort = "1JN", USFM_Num = 63},
    new Book{BookID = "64", BookNameShort = "2JN", USFM_Num = 64},
    new Book{BookID = "65", BookNameShort = "3JN", USFM_Num = 65},
    new Book{BookID = "66", BookNameShort = "JUD", USFM_Num = 66},
    new Book{BookID = "67", BookNameShort = "REV", USFM_Num = 67}
};

With the Book class defined as:

public class Book
{
    public string BookID { get; set; }
    public string BookNameShort { get; set; }
    public int USFM_Num { get; set; }
}

I'm not sure if this is something that could be useful in this library or not, but I'll be needing this eventually. Also note, that I've limited this list to the standard 66 books of the Bible and not all the supplemental books. Obviously, this list could be expanded to include those as well.

Thoughts on including something like this and if there are any breaking issues with making this a VMarker attribute?

@rbnswartz
Copy link
Member

So I'm interested in this because we're going to need this before too awful long. Craig (aka PurpleGuitar) and I were talking about this. I don't really want to add a field for this specific case I think an extension method would work to generate the data in the format that you need. I'm also debating on adding a general metadata functionality as well as a way for people to hook into the lexing/parsing so we can generically handle additional metadata that people

Currently the functionality you're looking for is accomplishable via GetHierarchyToMarker but it is horribly inefficient, especially in large documents.

I'm thinking of doing several things

  1. Adding a generic metadata functionality so that people can add whatever custom data they want to a marker
  2. Adding an overridable handler in the parser/lexer to allow people to be able to populate this data and or do really custom things with their USFM
  3. Adding a reference to chapter/book to verse markers either as a field or using custom metadata
  4. I could do things to make GetHierarchyToMarker more efficient such as adding a field on markers that point to it's parent, that would also make it easy to implement this functionality but then we run the risk of if/when a document has children moved (which I think is unlikely) it will then be pointing possibly to a wrong parent. We could add a method for that also.

What are your thoughts @GeoDirk @PurpleGuitar ?

@GeoDirk
Copy link
Contributor Author

GeoDirk commented Jun 4, 2021

All of the above would work but the easiest to implement and still be useful to folks would be #3. The renderer that I have derived this last week takes care of the B\C\V format in my output format. So I'm set for what I need. But I believe that the larger use-case of being able to quickly drill down to the right verse will be desirable going forward for the library. Especially for those cases where your app makes a change to a verse and then you need to go back and update the tree with the changes to that verse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants