avendesora / pythonbible

A python library for validating, parsing, normalizing scripture references and retrieving scripture texts (for open source and public domain versions)
https://docs.python.bible
MIT License
60 stars 12 forks source link

Words in text are interpreted as a reference #151

Open christopherpickering opened 8 months ago

christopherpickering commented 8 months ago

Thanks for this :)

When trying to get references from text strings sometimes a word matching a bible book returns a full book reference. For example, the word "mark" in here is giving me an extra ref. Is there a way we can add a flag on the get_references function to say if a chapter number is required in the match?

text = """This one thing I do, forgetting those things which are behind.... I press toward the mark
    for the prize of the high calling of God in Christ Jesus. Phil 3:13, 14"""
references = bible.get_references(text)

print(bible.format_scripture_references(references))

#Mark;Philippians 3:13-14
avendesora commented 8 months ago

Hi Christopher,

Good catch! I'll work on getting a unit test that reproduces this and then implementing a solution for it.

Thanks, Nathan

the-pied-shadow commented 7 months ago

Hey Nathan, as opposed to creating a new issue, I felt adding to this one made sense. As Christopher mentioned, it would be great to have a flag which requires a chapter number. Additionally, it would also be great to require a verse number. One of the issues I'm having is that if the text includes something like Genesis 30, it returns the entire chapter 30. It makes sense, but due to my use case this is a problem. I can detect if a reference is an entire chapter but checking the verses to see if they are the start and end of the chapter, but then I can't tell the difference between a reference like Malachi 4 and Malachi 4:1-6. This means I can't myself remove references that didn't include verse numbers because I have no way of telling the difference in the reference object.

Also like Christopher mentioned, thanks for this. What an awesome tool so far!

avendesora commented 6 months ago

Still getting caught up on everything here on the open-source side of life after a busy season...

This sounds like a good suggestion. Let me think about it for a little bit and then play around with implementing it to see what, if any, unintended consequences pop up. But, I think this is something that is doable and useful.