5
2
mirror of https://github.com/getbible/v2_builder.git synced 2024-11-24 11:37:33 +00:00
Go to file
2017-12-30 11:39:45 -05:00
kjv.json initial commit 2017-12-30 11:22:50 -05:00
LICENSE Create LICENSE 2017-12-30 11:39:45 -05:00
README.md Create README.md 2017-12-30 11:37:51 -05:00
sword_to_json.py initial commit 2017-12-30 11:22:50 -05:00

SWORD to JSON Generate json files of many Bible versions

The SWORD project provides modules freely for many different Bibles in many different languages. Often, Bible versions are provided in ways that are not convenient for developers to access. pysword is a Python package that provides an easy way to read the Bible modules from SWORD as part of your Python program.

This project leverages pysword to generate a json file from a SWORD module. As Bible translations are available in dozens of languages, this provides an easy way to generate a json version of many different Bible versions. An example is included in the project of the public domain KJV version in kjv.json.

As an example, here is the first part of the Bible so that you can see how the file is formatted.

{
    "books": [
        {
            "name": "Genesis",
            "chapters": [
                {
                    "chapter": 1,
                    "verses": [
                        {
                            "chapter": 1,
                            "text": "In the beginning God created the heaven and the earth.",
                            "verse": 1,
                            "name": "Genesis 1:1"
                        },

How to generate

Currently, due to pysword limitations, only Bible modules are supported, not dictionaries and commentaries. Additionally, this project only supports generating a json file that contains all of the text of the Old and New Testaments of a given Bible module.

First, you will need to install pysword. This can be done using pip: pip install pysword

Next, you can run using this format: python sword_to_json.py --source_file KJV.zip --bible_version KJV --output_file new.json

  • source_file Location of the zipped module you are trying to read. You can pass the filename if you're in the same directory or you can also pass a relative or absolute folder path.
  • bible_version Name of the module you are trying to load, as a SWORD module can include more than one Bible version. If you get the module from the SWORD project's index, the Name column has what you can pass in here.
  • output_file Location of the json file to be written to disk. As with the source file, you can pass the filename if you're in the same directory or you can also pass a relative or absolute folder path.

Note: It can take up to a few minutes to generate the json for any given Bible version. It takes approximately one minute to run on my machine.