openbibleinfo / Bible-Passage-Reference-Parser

Coffeescript to identify and understand Bible references like "John 3:16."
221 stars 64 forks source link

Parsing a larger text block with full and partial Bible references #39

Closed renehamburger closed 4 years ago

renehamburger commented 6 years ago

The .parse() works very well in returning all full Bible reference contained in a larger block of text. In contrast, .parse_with_context() for partial references is not able to find several partial references in a text block, but needs to be given the exact partial reference for parsing.

So there seems to be no out-of-the box way to the retrieve & parse the passages from a text like 'In Gen 3... But in verse 15...'. Or is there?

My current workaround is to use .parse() to find & parse all complete references. And to then look for all numbers in the remaining text blocks and check them with .parse_with_context(), both with and without a possible prefix like 'verse'.

Is anyone aware of an easier way to do this with this parser?

chriswep commented 5 years ago

with what solution did you end up @renehamburger ? Scratching my head on this one too. If you want to share any code you came up with, i'd appreciate!

openbibleinfo commented 4 years ago

Hi, this is what I use: https://gist.github.com/openbibleinfo/f0bb89d38cd8baa9298dbe97cfaa2251

It listens for a "q" and an optional "context" argument on port 3000. I use another language (such as PHP) to POST to this endpoint. The resulting text has tags around ones found by the BCV parser and tags found by the handle_extra function.

The HTTP part of this approach might be overkill for what you need.

renehamburger commented 4 years ago

Thanks for sharing this, @openbibleinfo!

Here's my solution, which is largely independent of the language. I am basically looking for any numbers in the text and extend the selection to the front and back to pass it to the bcv instance. The text is the text in between two already recognised passages and the previous passage is used as the context for an partial references found in the text.

When it comes to finding references in html, blinx.js does a pretty good job!