Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python module: Revised JSON structure and filters #175

Merged
merged 15 commits into from
Oct 10, 2022

Conversation

kavitharaju
Copy link
Collaborator

The python module, especially the to_dict() or --format json API, has been re-written completely with the following effects

  • The JSON output has been changed
USFM New JSON(with all contents) Old JSON(with filter=all)

\id GEN
\h Genesis
\c 1
\p
\v 1 test verse

{"book": {
  "bookCode": "GEN",
  "headers": [
      {"h": "Genesis"}
   ],
   "chapters": [
      {"chapterNumber": "1",
         "contents": [
            {"p": [{"verseNumber": "1"},
                   {"verseText": "test verse"}]
            }]
      }]
}}

[{"book": [
    {"id": ["\\id ",
            {"bookcode": ["GEN"]},
            {"description": "\n"}]}]
 },
 {"hBlock": [{"h": [
                    {"hTag": ["\\h"," "]},
                    {"text": "Genesis\n"}]}]
 },
 {"chapter": [
            {"c": ["\\c ",{"chapterNumber": "1"}]},
            {"paragraph": [{"p": [
                            "\\p",
                            {"v": ["\\v ",{"verseNumber": "1 "}]},
                            {"verseText": [{"text": "test verse\n"}]}
                        ]}]
            }]
 }
]
  • Filter options changed
    [--filter {scripture-bcv,notes,scripture-paragraph,all}]
    to
    [--filter {BOOK_HEADERS,PARAGRAPHS,TITLES,SCRIPTURE_TEXT,NOTES,ATTRIBUTES,MILESTONES,STUDY_BIBLE}]

Also, the way filter is used has been changed. Instead of selecting one option, now user can add more than one filter choice and include different combinations of the contents he needs to extract from the USFM. Example, scripture-and-notes, notes-and-milestones, scripture-and-titles, scripture-paragraphs-and-titles etc.

  • The to_list() or --format table API, used for getting TSV outputs, has been re-written to work according to the JSON changes. This API is internally dependant on the to_dict() api and just re-formats the dict output to a convenient list form. But this api cannot handle the paragraph filter option, as the nested structure of paragraphs is hard to implement in a table output format.

  • Added linting check on gitactions for the python module

  • As part of the above to_dict refactoring, one grammar rule had to be changed(toc) to follow the pattern of other marker rules. This results in a slight change in the syntax tree.

@kavitharaju kavitharaju added discuss Discuss about this python-module labels Sep 30, 2022
@kavitharaju kavitharaju marked this pull request as draft September 30, 2022 13:25
@kavitharaju kavitharaju marked this pull request as ready for review October 3, 2022 05:47
@joelthe1 joelthe1 merged commit 28e613a into Bridgeconn:version-3 Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Discuss about this python-module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants