bible-ref-parse 1.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +13 -14
- package/js/en_bcv_parser.js +3069 -2150
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -32,23 +32,22 @@ These usage examples are in Javascript. You can also use Coffeescript, of course
|
|
|
32
32
|
To install from the command line:
|
|
33
33
|
|
|
34
34
|
```shell
|
|
35
|
-
npm i bible-
|
|
35
|
+
npm i bible-ref-parse
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
### Importing the module
|
|
39
39
|
|
|
40
|
+
ESM:
|
|
40
41
|
```javascript
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
import * as parserModule from 'bible-ref-parse/js/en_bcv_parser';
|
|
43
|
+
const parser = new parserModule.bcv_parser();
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
After downloading the language file you want:
|
|
46
|
+
CommonsJS:
|
|
48
47
|
|
|
49
48
|
```javascript
|
|
50
49
|
var bcv_parser = require("/path/js/en_bcv_parser.js").bcv_parser;
|
|
51
|
-
var bcv = new bcv_parser;
|
|
50
|
+
var bcv = new bcv_parser();
|
|
52
51
|
```
|
|
53
52
|
|
|
54
53
|
### Parsing
|
|
@@ -361,11 +360,11 @@ The parser is quite aggressive in identifying text as Bible references; if you j
|
|
|
361
360
|
|
|
362
361
|
The parser spends most of its time doing regular expressions and manipulating strings. If you give it a very long string full of Bible references, it could block your main event loop. Depending on your performance requirements, parsing large numbers of even short strings could saturate your CPU and lead to problems in the rest of your app.
|
|
363
362
|
|
|
364
|
-
In addition, a number of the tests in the "real-world" section of [`src/core/spec.coffee`](https://github.com/
|
|
363
|
+
In addition, a number of the tests in the "real-world" section of [`src/core/spec.coffee`](https://github.com/bibleutils/bible-ref-parse/blob/master/src/core/spec.coffee) have comments describing limitations of the parser. Unfortunately, it's hard to solve them without incorrectly parsing other cases—one person intends `Matt 1, 3` to mean `Matt.1,Matt.3`, while another intends it to mean `Matt.1.3`.
|
|
365
364
|
|
|
366
365
|
## Tests
|
|
367
366
|
|
|
368
|
-
One of the hardest parts of building a BCV parser is finding data to test it on to tease out corner cases. The file [`src/core/spec.coffee`](https://github.com/
|
|
367
|
+
One of the hardest parts of building a BCV parser is finding data to test it on to tease out corner cases. The file [`src/core/spec.coffee`](https://github.com/bibleutils/bible-ref-parse/blob/master/src/core/spec.coffee) has over 3,700 tests that illustrate the range of input that this parser can handle.
|
|
369
368
|
|
|
370
369
|
Separate from this repository are four data files that you can use to test your own parser. Derived from Twitter and Facebook mentions of Bible references, the dataset reflects how people really type references in English. It includes 4.7 million unique strings across 180 million total mentions. (For example, the most-popular string, "Philippians 4:13", is mentioned over 1.3 million times.)
|
|
371
370
|
|
|
@@ -481,7 +480,7 @@ The BCV parser supports several versification systems (described above). The app
|
|
|
481
480
|
|
|
482
481
|
The Javascript files that don't start with `en` provide support for other languages.
|
|
483
482
|
|
|
484
|
-
Using the files in [`src/template`](https://github.com/
|
|
483
|
+
Using the files in [`src/template`](https://github.com/bibleutils/bible-ref-parse/tree/master/src/template) as a base, you can add support for additional languages; just use the appropriate ISO 639 language prefix. I'm happy to accept pull requests for new languages.
|
|
485
484
|
|
|
486
485
|
### Supported Languages
|
|
487
486
|
|
|
@@ -550,7 +549,7 @@ When using `<script>`s on the web, be sure to serve them with the `utf-8` charac
|
|
|
550
549
|
|
|
551
550
|
### Cross-Language Support
|
|
552
551
|
|
|
553
|
-
Two files in [`/js`](https://github.com/
|
|
552
|
+
Two files in [`/js`](https://github.com/bibleutils/bible-ref-parse/tree/master/js) provide support for identifying translations in multiple languages at one time (e.g., "Matthew 2, Juan 1"). You can use this support if you don't know ahead of time what language someone might be using.
|
|
554
553
|
|
|
555
554
|
The files are:
|
|
556
555
|
|
|
@@ -615,11 +614,11 @@ May 4, 2017 (2.0.1). Fixed a bug in calculating positions for non-English Psalm
|
|
|
615
614
|
|
|
616
615
|
May 1, 2016 (2.0.0). Added additional Vulgate versification beyond Psalms. Because these changes are technically backwards-incompatible, the major version number is incrementing, but in practice the changes are minor.
|
|
617
616
|
|
|
618
|
-
November 1, 2015 (1.0.0). Added `punctuation_strategy` option to replace the "eu"-style files that were previously necessary for this functionality. Added `single_chapter_1_strategy` option to allow parsing of "Jude 1" as `Jude.1.1` rather than `Jude.1`. Fixed crashing bug related to dissociated chapter/book ranges. Upgraded to the latest versions of pegjs and Coffeescript. Added npm compatibility. Added support for a "next verse" syntax, which is used in Polish ("n" for next verse, compared to "nn" for "and following"). The parsing grammar includes this support only when the $NEXT variable is set in the language's data.txt file (only Polish for now). Thanks to [nirski](https://github.com/
|
|
617
|
+
November 1, 2015 (1.0.0). Added `punctuation_strategy` option to replace the "eu"-style files that were previously necessary for this functionality. Added `single_chapter_1_strategy` option to allow parsing of "Jude 1" as `Jude.1.1` rather than `Jude.1`. Fixed crashing bug related to dissociated chapter/book ranges. Upgraded to the latest versions of pegjs and Coffeescript. Added npm compatibility. Added support for a "next verse" syntax, which is used in Polish ("n" for next verse, compared to "nn" for "and following"). The parsing grammar includes this support only when the $NEXT variable is set in the language's data.txt file (only Polish for now). Thanks to [nirski](https://github.com/bibleutils/bible-ref-parse/issues/16) for identifying this limitation.
|
|
619
618
|
|
|
620
619
|
May 4, 2015 (0.10.0). Hand-tuned some of the PEG.js output to improve overall performance by around 50% in most languages.
|
|
621
620
|
|
|
622
|
-
March 16, 2015 (0.9.0). Added [`parse_with_context()`](#parse_with_context) to let you supply a context for a given string. Added Welsh. Fixed some Somali book names. Added missing punctuation from abbreviations in some languages. Reduced size of "eu" files by omitting needless duplicate code. Improved testing code coverage and added a [fuzz tester](https://github.com/
|
|
621
|
+
March 16, 2015 (0.9.0). Added [`parse_with_context()`](#parse_with_context) to let you supply a context for a given string. Added Welsh. Fixed some Somali book names. Added missing punctuation from abbreviations in some languages. Reduced size of "eu" files by omitting needless duplicate code. Improved testing code coverage and added a [fuzz tester](https://github.com/bibleutils/bible-ref-parse/blob/master/bin/fuzz/fuzz_lang.coffee), which uncovered several crashing bugs.
|
|
623
622
|
|
|
624
623
|
November 3, 2014 (0.8.0). Fixed two bugs related to range rewriting. Updated frak to the latest development version. Added quite a few more languages, bringing the total to 46.
|
|
625
624
|
|