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

Design and define the logic for calculating the GL quote #167

Open
mandolyte opened this issue Mar 10, 2023 · 2 comments
Open

Design and define the logic for calculating the GL quote #167

mandolyte opened this issue Mar 10, 2023 · 2 comments

Comments

@mandolyte
Copy link
Collaborator

mandolyte commented Mar 10, 2023

Sketched out the essentials for the quote package (the single word use case only):
Where values are mentioned, they come from the TN for 1PE 1:1, id=g6b4.
This use case is for a single original word, not phrases or ellipses.

Prerequisites

  • both the original language and GL must be aligned

Notable Conditions

  • the GL verse may not match the original language verse. This will happen when the corresponding GL verse is inside a verse span
  • it is the application responsibility to obtain the USFM and to convert it to usfm-json format
  • it is the application responsibility to provide the values from the Translation Note for which the GL Quote needs to be calculated

Inputs

  • book usfm JSON for original language (ie, Greek or Hebrew)
  • book usfm JSON for target or GL language
  • values from row in a TSV7 Translation Notes file, namely:
    • reference (such as "1:1")
    • Original word (such as "Πέτρος")
    • Occurrence (such as "1")

Returns

An object with the following properties:

  • the target mapped word
  • the target mapped occurrence
@mandolyte
Copy link
Collaborator Author

mandolyte commented Mar 10, 2023

Notes

Below find the USFM and JSON for the English UST for the example reference (1PE 1:1).

The process is roughly as follows:

  1. find the chapter and verse (remember it may be inside a verse span!)
  2. loop thru the verse objects to find the zaln tags
  3. for the tag with the "content" that matches the original word (in this case Πέτρος) and the occurrence number, then...
  4. create the return object, which would be something like this:
{
    content: "I am Peter",
    occurrence: "1"
}

Here is the USFM from 1PE 1:1.

\v 1 {\zaln-s \|x-strong="G40740" x-lemma="πέτρος" x-morph="Gr,N,,,,,NMS," x-occurrence="1" x-occurrences="1" x-content="Πέτρος"\*\w I\|x-occurrence="1" x-occurrences="3"\w*
\w am\|x-occurrence="1" x-occurrences="3"\w*}
\w Peter\|x-occurrence="1" x-occurrences="1"\w*\zaln-e\*,

Here is the corresponding JSON:

{
    "1": {
        "1": {
            "verseObjects": [
                {
                    "type": "text",
                    "text": "{"
                },
                {
                    "tag": "zaln",
                    "type": "milestone",
                    "strong": "G40740",
                    "lemma": "πέτρος",
                    "morph": "Gr,N,,,,,NMS,",
                    "occurrence": "1",
                    "occurrences": "1",
                    "content": "Πέτρος",
                    "children": [
                        {
                            "text": "I",
                            "tag": "w",
                            "type": "word",
                            "occurrence": "1",
                            "occurrences": "3"
                        },
                        {
                            "type": "text",
                            "text": " "
                        },
                        {
                            "text": "am",
                            "tag": "w",
                            "type": "word",
                            "occurrence": "1",
                            "occurrences": "3"
                        },
                        {
                            "type": "text",
                            "text": "} "
                        },
                        {
                            "text": "Peter",
                            "tag": "w",
                            "type": "word",
                            "occurrence": "1",
                            "occurrences": "1"
                        }
                    ],
                    "endTag": "zaln-e\\*"

@mandolyte
Copy link
Collaborator Author

mandolyte commented Mar 10, 2023

In case it is useful, here is a little node.js script to convert USFM to JSON:

import usfmjs from 'usfm-js';
import { readFile, writeFile } from 'fs';

let testinput = '1pe_usfm.txt';
let jsoninput;
let chapters;

readFile(testinput, (err, data) => {
    if (err) throw err;

    let s = ""+data;
    jsoninput = usfmjs.toJSON(s);
    chapters = jsoninput.chapters;
    writeFile(testinput+".json",JSON.stringify(chapters, undefined, 4),
        function(err) {
            if (err) {
                return console.log(err);
            }
        }
    );

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant