0 votes

I have an NT Nzema in which paragraph markers are applied in front of each verse number. Does anyone know how to apply paragraph markers from a sample project to this project

Paratext by (105 points)
reshown

10 Answers

0 votes
Best answer

I tried to take a stab at writing a custom cms Python script, but hit a couple of roadblocks:

  1. When I try to write the modified text back out (with .putText), I get an error that the Lock was not obtained:
    image
    But the file isn’t open anywhere else that I can tell. I’ve even tried to process a book that is not open in Paratext, but got the same result.

  2. In the cms file I created an option to select a standard text (to copy paragraph markers from):

\optionName StandardText
\optionLocalizedName StandardText
\optionDescription Select standard text to copy paragraph markers from.
\optionDefault TOB
\optionListAllTexts

But this only allows me to select projects. Is there a way that I can select a resource text like TOB? They used to be similar to projects in earlier versions of Paratext, but it seems that they are very different animals now.

  1. I can use sys.stderr.write to output to a dialog on the screen, but I can’t seem to write to the List window. I based my script off of ConvertAFR.py, which only writes to sys.stderr. Other scripts like comparePunctuation.py seem to use a different path, starting with checking.setupCheck(). Is that path required to write to the List window? Is there some documentation on this? (UPDATE: I just found README.pdf, which I’m looking through now…)

Thanks for any input on these questions?

by (1.3k points)
reshown

Thanks for trying jeffh! I don’t have an answer to 1 or 3 but can confirm that the custom scripts are no longer allowed to access Paratext Resource files. This was an intentional move to prevent people making their own local copies of copyright-protected texts.

I think the best way to get a list of all the places a \p marker occurs would be to use RegExPal to “Extract” a list by searching the Resource text (which, interestingly, is allowed in RegExPal!) with an expression like this:
\\p[ |\r?\n]


And then you would still need to massage that list back into the target project:
GEN 2:3: \p
GEN 2:4: \p
GEN 2:7: \p
GEN 2:9: \p
GEN 2:14: \p
GEN 2:17: \p
etc.
Notice that the reference would actually need to be incremented by 1 if you’re looking for which verse to insert it before. If you can insert the \p marker after the above-mentioned list of verses then you could use the list as is.
That’s as far as I can help. Hopefully someone else can help you with 1 & 3.
  1. For a CMS script to write back to a project, the flag \outputProject should be in the CMS file. We also try to parse the Python script to see if it outputs to a project, but that may not work 100% of the time.
  2. Resources are still very similar to projects (they are just zipped projects), but as @Mark+P said, resources access has become much more restricted in PT8+. This is due to pressure from the rights holders and us wanting to respect their content.
  3. To output to a list, the flag \toList must be in the CMS file.

Thanks for the input.

  1. OK, I hadn’t added the \outputProject flag before because in general I want the output to go to the same project as the input, but I’ve added this flag now, and I can indeed write back to the project. I guess the user may want to actually send the output to a separate project, so that’s not such a bad thing.

  2. I’ll probably use @Mark+P’s idea to use RegEx Pal to extract a list of references, and then use that list as an input file to the script. Just a note, I’ll probably search for space after \p and give that list to the user as a manual list of references to work on, as those are paragraphs in the middle of a verse, and no automated process will be able to position them accurately. I’ll just look for \p markers followed by \r?\n as the ones that I will try to position automatically in the script.

  3. It appears that \outputProject and \toList are mutually exclusive? I don’t see a single .cms file with both. (I.e. you can’t ooutput to a project and also write text out.) I tried \toText as well, but that didn’t seem to work either. Now that I have the \outputProject working, that’s not quite so critical, but would still be nice to have an easy output mechanism other than sys.stderr - which just accumulates text and outputs it in a dialog (which can fill up pretty fast…).

The consultant just said that “The Good News Bible” would be the right resource to use, sorry for the change.

They shouldn’t be mutually exclusive. \toText and \toList are mutually exclusive.

With either \toList or \toText, the following lines in my script do nothing:

sys.stdout.write(dstText + "\n")
print "# Testing"

Is there something else I need to do?

0 votes

Could you please clarify whether this is what you mean:
a) Remove all the \p markers from this project
and then
b) Insert \p markers from another project into this project so that the location of paragraph markers match

Is that what you are trying to do?

by (2.3k points)

Yes, that is what I’m trying to do.

anon023887

0 votes

I don’t know of an easy way to add \p references from a model project when the text already exists. What wasn’t that hard was to remove all the \p markers from this project, (search for \p, replace with nothing). Then I thought of adding \p after every \s1 or \s1 followed by \r. I couldn’t figure out how to do this with a regular expression, but it was not hard to do with a CC table:

begin > use(main)

group(main)

'\s1 ' > dup use(addp)

group(addp)
'\r ' > dup
'\v ' > '\p \v ' use(main)

I then imported that file back into Paratext, found the process hadn’t added a \p at the beginning of chapter 1 because there is no heading until after verse 4. It also hadn’t added a \p at the beginning of chapter 9 because the \s1 there has no text in it.
When I ran the basic check for markers it also showed me a few \ characters with no marker, which I also fixed. There were lots of “empty marker \add” which I have not fixed.

So if this version is helpful to you, here it is:

by [Expert]
(3.0k points)
0 votes

I’m guessing that sewhite’s solution (above) has got you closer to your goal, but there will still be a whole bunch of \p markers in the original text that would have been missed. One way of finding which ones are missing is to use Tools > Checklists > Markers…
Then under Settings… type in \p for “Markers to be displayed” and Select the option to “Hide Matches” as shown below:
image
Then you will see each place where the markers are missing and can manually :frowning: fix them.

The only other way to solve this problem that I can think of is for someone to write a custom tool (say in Python) which does it all for you automatically. We have a tool to insert Cross-references like this, but AFAIK we don’t yet have something that will copy \p markers from one project to another.

Hopefully someone will pipe up and contradict me by saying “Here’s my solution!”; or someone else will offer to write you a custom script. :slight_smile:

by (2.3k points)

You could use the Paratext Tool:

Tools/Checklists/Markers

Here you can choose the texts to compare and the markers to compare and edit your own text.

Great, thank you very much for the solution

anon023887

0 votes

@anon023887 Can you tell us which resource text you are likely to want to use as the template for the paragraph markers? E.g. TOB or NBS?

by (1.3k points)

I spoke with a consultant here, he proposes BDS as a resource text.

0 votes

Please see the information about \toList inside the README.pdf file in the cms directory:

Lines must have format “GEN 3:11\t\tThe text of the message.”

(The list items need a reference)

by [Expert]
(16.2k points)

reshown

I’ve also tried outputting with a reference, and it still didn’t do anything. And it appears that prefixed by “#” should be a comment

0 votes

@jeffh, Could you send me ([Email Removed]) your CMS and script file so I can look at what is going on?

by [Expert]
(16.2k points)
0 votes

I have written a Python script which might solve @anon023887’s problem. It uses a text file with the references of all of the paragraph markers from a reference project (the references for GNTD NT are supplied) and applies those paragraph markers in the project you specify.

To use the script, put the four files from this zip file into the C:\My Paratext 8 Projects\cms folder:
ApplyParagraphMarkers.zip (8.4 KB)
(If you use a different Paratext project folder, you will need to edit the .py file with the path to the GNTD_NT_para.txt file. @anon291708 Is there a way to start the script in the cms folder rather than the program folder? That would be nicer…)

Restart Paratext (so that it will see the new .cms file). Then in the project menu of the project where you want to apply the paragraph markers, (expand to full menus) select Tools > Custom Tools > Unsupported > Apply Paragraph Markers [CAN CHANGE TEXT]. The Input Project should already be the current project. Leave the Output Project as the same project if you want to make the changes directly in the project. (N.B. you should send Output to a test project for initial tests, or at least mark a point in the history of your project.) Select the books to process. Then click OK to apply the paragraph markers to the selected books.

References that cannot be processed will be noted in the closing dialog, so that you can consider placing them manually:
image
The script can’t place a \p before verse 6b, because it is in the middle of a verse. So you will need to consider that \p placement manually in your text. I don’t know why the script is seeing MATMAT 1:21 (it’s not in the text file), but in this case you will need to consider inserting a \p manually before MAT 1:22 as well.

Speaking of placing \p markers manually, there is a separate file included: GNTD_NT_para_within_verses.txt, which is a list of 262 references of \p markers in the GNTD NT that are in the middle of verses, i.e. the \p is followed by a space instead of a line break. Each of those cases will need to be considered manually in your text, as the script can’t place those \p markers automatically.

I include below the description of the script that appears when you run it (from the cms file), which might provide some additional help.

Let me know if you have questions or comments.


Description: (Is there a way to get \n in the description without a new line?)
Apply paragraph markers from a reference list to the selected books of a project. If the Output Project is the same as the Input Project, the changes will be made “in place”.

The reference list contains one reference per line, indicating the places that paragraph markers were found in the reference text, e.g. “MAT 5:0”, “MAT 5:10”. The markers will be placed before the following verse, for this example “MAT 5:1” and “5:11”. Paragraph markers in the text before verses NOT in the reference list will be removed, but generally a paragraph marker in the middle of the verse will not be removed.

The reference list is hard coded in the ApplyParagraphMarkers.py script, as “C:\My Paratext 8 Projects\cms\GNTD_NT_para.txt”. You must edit the script if you want to change the list used, or if you have a non-standard Paratext project directory. There is also a file “GNTD_NT_para_within_verses.txt” which gives references for paragraph marks found in the middle of verses. The script can’t place these automatically, so you will need to manually consider placement of \p markers near each of these references.

To produce a new reference list, use RegEx Pal to Extract (with Include References) this term (no quotes, and remove the space before the ‘n’): “\p\r?\ n” Select the output, copy and paste in a text editor, remove “:\t \p” from each line to leave just the reference, then save it as a text file. You will likely want to also Extract this term: "\p " (with space). This will provide a list of paragraph markers that are in the middle of verses. They cannot be placed automatically by the script, so they should be considered manually.

by (1.3k points)
0 votes

Nice work jeffh! I look forward to trying it out on a test project next week. Thanks for persevering through the difficult bits - and presumably learning lots along the way!

by (2.3k points)

Merci infiniment jeffh pour le script, j’ai dézippé les 4 fichiers et je les ai placé dans le dossier “cms” mais je retrouve pas le chemin que tu indiques:
Tools > Custom Tools > Unsupported > Apply Paragraph Markers [CAN CHANGE TEXT].

@anon023887, The path he gave you is for Paratext 9.0. In Paratext 8.0, the path should be:
Checking > Advanced > Unsupported > Apply Paragraph Markers [CAN CHANGE TEXT]

Thanks, it’s ok

0 votes

jeffh - thanks for working on this. For those who may not be aware, you can open the list that you created for verses within the text by using the “Open List…” option in the list window menu. The option defaults to look for a .ref file, but if you select .txt then you can choose the “GNTD_NT_para_within_verses.txt” in the cms folder and access these passages.

by (7.9k points)

This is an excellent piece of advice from anon848905. Then you can have your translation open, have GNTD open, then open the list of paragraphs within verses (using Open List, selecting .txt files as the file type, and opening the file from the cms folder), and you can one by one go through those 262 verses, to see if you should be adding a paragraph mark in the middle of each verse in your translation or not.

Do remember that you have to go through that list!

Also, if you are planning on using this tool for the Old Testament, make sure to use a reference translation for the paragraph markers that uses the same versification! I image GNTD isn’t the same versification as most translations done in French-speaking countries…

Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
They devoted themselves to the apostles’ teaching and to fellowship, to the breaking of bread and to prayer.
Acts 2:42
2,450 questions
5,139 answers
4,835 comments
1,240 users