boblail / pericope Goto Github PK
View Code? Open in Web Editor NEWA simple Bible reference parser
A simple Bible reference parser
When using Pericope::parse, if the second book in a pair begins with a digit, then that digit will be included in the 1st pericope, and the second book won't be recognized. An example will clarify:
blah Acts 20:21; Exodus 5:1-14 blah
is parsed correctly, but
blah Acts 20:21; 2 Kings 5:1-14 blah
is parsed as "Acts 20:21, 2". This one is recognizably an error because the verses shouldn't decrease, but something like "Exodus 1:10-2:1; 2 Kings 5:1-14" would be trickier.
I've never seen a BNF for Bible verses, I would think that ';' can be used to separate blocks of verses, but only if it's not being used to separate whole pericopes.
Hi @boblail, I'm using your code successfully with a Twitter bot @opentxtbook. However, I have noted that Pericope cannot parse a passage written like Psalm1
or Ps1
. It is requiring it be written Psalm 1
or Ps 1
to parse successful.
This can be a problem since some people may not put a space between book and chapter.
Your code is greatly appreciated. Many thanks
There seems to be a parsing problem with 1 Cor. In my fork, I have added some tests that demonstrate the issue. When text precedes an abbreviated reference to 1 Corinthians (i.e. 1 Cor.) the pericope isn't picked up.
see https://github.com/jaredjackson/pericope/blob/master/test/additional_pericope_test.rb
Should this be to_i
instead of to_a
for Verse
?
pericope/lib/pericope/verse.rb
Line 28 in 1b8c582
I'd love for single chapter books to resolve just the same as a whole chapter reference. For example:
# nothing returned for this single chapter book
irb(main):020:0> Pericope.parse_one('Philemon')
=> nil
# full chapter verse range already handled for single chapter book WITHOUT chapter designation
irb(main):021:0> Pericope.parse_one('Philemon 1-25')
=> Pericope(Philemon 1–25)
irb(main):022:0> Pericope.parse_one('Ezekiel 1')
=> Pericope(Ezekiel 1)
# single chapter book could be similar to single chapter of multi chapter book
irb(main):023:0> Pericope.parse_one('Philemon 1-25').ranges
=> [57001001..57001025]
irb(main):024:0> Pericope.parse_one('Ezekiel 1').ranges
=> [26001001..26001028]
Right now we're handling this exception in a wrapper outside Pericope but would love if this was seen as a valid reference string. Thanks for the great library!
For example, I need to be able to parse the following string:
“A wise son makes a glad father, but a foolish man despises his mother.”
Proverbs 15:20 ESV
http://bible.com/59/pro.15.20.esv
I need to discard the link (I can do that with regex), but then know that sentence (which could be multiple sentences, or a partial sentence) are the words, and then Proverbs 15:20 has a book, chapter, verse, and then a translation.
It looks like the text parse makes these each elements in an array. Unless I am reading the docs wrong....but was hoping something could tell me the reference and then the actual text. Thanks!
I am guessing that @range lets me extract chapter and verse?
@ranges=[35003019..35003019]
Is the last three digits always verse, the second three always chapter and the first two digits the book?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.