Skip to main content

Tools to detect and convert between Bible versifications

Project description

Contributors Forks Stargazers Issues MIT License

Versification Utils

Tools to detect and convert between Bible versifications
Report Bug · Request Feature

Getting Started

Installation

To install, use your favorite package manager and do the equivalent of:

pip install versification-utils

Usage

versification-utils provides three main functions: detect, remap_verses, and to_vref.

Detecting Versification

The detect function analyzes a list of verse references and returns the versification system that best fits the references. The function returns a string with the name of the versification system (or a list of versification schemas, if there was a tie).

from versification_utils import detect

detect(["JHN 3:16", "JHN 3:17", "JHN 3:18"])
# ['eng', 'rsc', 'rso', 'vul', 'org', 'lxx', 'unk']

The schemas are abbreviated as follows:

  • eng: English (Protestant)
  • rsc: Russian (Synodal)
  • rso: Russian (Orthodox)
  • vul: Vulgate
  • org: Original (Hebrew/Greek)
  • lxx: Septuagint
  • unk: Unknown

In this case, the verse references were insufficient to rule out any possibilities. But if we add more references, we can narrow down possibilities:

detect(["PSA 22:31", "PSA 23:6"])
# 'eng'

detect(["PSA 22:32", "PSA 23:6"])
# 'org'

Only the eng versification system ends Psalms 22 with v. 31 and 23 with v. 6. So the first example returns 'eng', while the second example returns 'org'. Technically, the diagnostics only examine the the last verse number of each chapter right now. This may change in future, so the detect function expects a list of USFM verse references. You should just pass in all the references you have (which would make for a convoluted example here).

Remapping Verses

If you know the versification schema your references follow, you can use the remap_verses function to convert them to another schema. This function takes a dictionary of verses that map the reference to the verse text, and returns a new dictionary with modified (remapped) references.

from versification_utils import remap_verses

verses = {
    "PSA 22:31": "The last verse of Psalm 22",
    "PSA 23:6": "The last verse of Psalm 23"
}

from_schema = "eng"
to_schema = "org"
new_verses = remap_verses(verses, from_schema, to_schema)
# {'PSA 22:32': 'The last verse of Psalm 22', 'PSA 23:6': 'The last verse of Psalm 23'}

from_schema = "eng"
to_schema = "lxx"
new_verses = remap_verses(verses, "eng", "lxx")
# {'PSA 21:32': 'The last verse of Psalm 22', 'PSA 22:6': 'The last verse of Psalm 23'}

Note: In the second example, the LXX chapters are offset by one.

Exporting a Vref File

If you have a dictionary of verses, you can export them to a vref file using the to_vref function. This function takes a target filename, dictionary of verses (like the remap_verses function), and the versification schema of the verses. If the verses are not in org versification, to_vref will remap them to org before exporting.

from versification_utils import to_vref

verses = {
    "PSA 22:31": "The last verse of Psalm 22",
    "PSA 23:6": "The last verse of Psalm 23"
}

to_vref("eng-my_translation.vref", verses, "eng")
# The vref file "./eng-my_translation.vref" will be created

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.md for more information.

(back to top)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

versification_utils-0.0.1.tar.gz (122.9 kB view details)

Uploaded Source

Built Distribution

versification_utils-0.0.1-py3-none-any.whl (128.0 kB view details)

Uploaded Python 3

File details

Details for the file versification_utils-0.0.1.tar.gz.

File metadata

  • Download URL: versification_utils-0.0.1.tar.gz
  • Upload date:
  • Size: 122.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for versification_utils-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d1c8e371b87d8fae5c0c1f583b38ce2b789b9e31db697ebc190a0e897186601a
MD5 28899f817f428aebbee41bc8e2fafd41
BLAKE2b-256 99312e371a285d111380afb88b0a3ff88f04dfea539b9a7fdc82d09dd4dcbf2a

See more details on using hashes here.

File details

Details for the file versification_utils-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for versification_utils-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce10e95054a3e38f86758a7933d5c287caf33768858a184d25722db87abc7425
MD5 92c28580f7b0f73bbe659ee39562b1eb
BLAKE2b-256 bb687d31baf3c969693798910a06160ad5413b7ef17add8c6298045d879a3e97

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page