Skip to content

Commit

Permalink
MyBibleZone: Use strong_numbers_prefix on import
Browse files Browse the repository at this point in the history
When this property is set in info table, all Strong's numbers that do
not have a prefix themselves will get this prefix, instead of the
default prefix (H in OT, G in NT).
  • Loading branch information
schierlm committed May 20, 2024
1 parent fd08d41 commit 3bbdf13
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public Bible doImport(File inputFile) throws Exception {
}
db.beginTransaction(SqlJetTransactionMode.READ_ONLY);
String bibleName = null;
char defaultStrongsPrefix = '\0';
MetadataBook mb = new MetadataBook();
ISqlJetCursor cursor = db.getTable("info").open();
while (!cursor.eof()) {
Expand All @@ -207,6 +208,9 @@ public Bible doImport(File inputFile) throws Exception {
System.out.println("WARNING: Skipping malformed metadata property " + fn);
}
}
if (fn.equals("strong_numbers_prefix") && fv.length() == 1) {
defaultStrongsPrefix = fv.charAt(0);
}
cursor.next();
}
cursor.close();
Expand Down Expand Up @@ -304,7 +308,8 @@ public Bible doImport(File inputFile) throws Exception {
Chapter ch = bk.getChapters().get(c - 1);
Verse vv = new Verse(v == 0 ? "1/t" : "" + v);
try {
String rest = convertFromVerse(text, vv.getAppendVisitor(), hp, footnoteDB, new int[] { b, c, v }, bk.getId().isNT());
char strongsPrefix = defaultStrongsPrefix != '\0' ? defaultStrongsPrefix : bk.getId().isNT() ? 'G' : 'H';
String rest = convertFromVerse(text, vv.getAppendVisitor(), hp, footnoteDB, new int[] { b, c, v }, bk.getId().isNT(), strongsPrefix);
if (!rest.isEmpty()) {
System.out.println("WARNING: Treating tags as plaintext: " + rest);
vv.getAppendVisitor().visitText(rest.replace('\t', ' ').replaceAll(" +", " "));
Expand Down Expand Up @@ -432,7 +437,7 @@ private void convertFromHTML(String html, HyperlinkParser<RuntimeException> hp,
AbstractHTMLVisitor.parseHTML(vv, hp, html, "");
}

private String convertFromVerse(String text, Visitor<RuntimeException> vv, HyperlinkParser<RuntimeException> hp, SqlJetDb footnoteDB, int[] vnums, boolean nt) {
private String convertFromVerse(String text, Visitor<RuntimeException> vv, HyperlinkParser<RuntimeException> hp, SqlJetDb footnoteDB, int[] vnums, boolean nt, char strongsPrefix) {
int pos = text.indexOf("<");
while (pos != -1) {
String strongsWord = "";
Expand Down Expand Up @@ -460,7 +465,7 @@ private String convertFromVerse(String text, Visitor<RuntimeException> vv, Hyper
int[] snum = new int[txt.length];
char[] prefixHolder = new char[1];
for (int i = 0; i < txt.length; i++) {
snum[i] = Utils.parseStrongs(txt[i], nt ? 'G' : 'H', prefixHolder);
snum[i] = Utils.parseStrongs(txt[i], strongsPrefix, prefixHolder);
spfx[i] = prefixHolder[0];
if (snum[i] == -1) {
System.out.println("WARNING: Invalid Strong number: " + txt[i]);
Expand Down Expand Up @@ -495,7 +500,7 @@ private String convertFromVerse(String text, Visitor<RuntimeException> vv, Hyper
else
vv.visitGrammarInformation(spfx.length == 0 ? null : spfx, snum.length == 0 ? null : snum, rmac == null ? null : new String[] { rmac }, null).visitText(cleanText(strongsWord));
} else if (text.startsWith("<n>")) {
text = convertFromVerse(text.substring(3), vv.visitCSSFormatting("font-style: italic; myBibleType=note"), hp, footnoteDB, vnums, nt);
text = convertFromVerse(text.substring(3), vv.visitCSSFormatting("font-style: italic; myBibleType=note"), hp, footnoteDB, vnums, nt, strongsPrefix);
if (!text.startsWith("</n>"))
System.out.println("WARNING: Unclosed <n> tag at: " + text);
else {
Expand All @@ -517,7 +522,7 @@ private String convertFromVerse(String text, Visitor<RuntimeException> vv, Hyper
text = text.substring(5);
} else if ((text.startsWith("<m>") && rawMorphology) || (text.startsWith("<f>") && rawFootnotes)) {
String tag = text.substring(1, 2);
text = convertFromVerse(text.substring(3), vv.visitExtraAttribute(ExtraAttributePriority.SKIP, "mybiblezone", "rawtag", tag), hp, footnoteDB, vnums, nt);
text = convertFromVerse(text.substring(3), vv.visitExtraAttribute(ExtraAttributePriority.SKIP, "mybiblezone", "rawtag", tag), hp, footnoteDB, vnums, nt, strongsPrefix);
if (!text.startsWith("</" + tag + ">"))
System.out.println("WARNING: Unclosed <" + tag + "> tag at: " + text);
else {
Expand All @@ -528,28 +533,28 @@ private String convertFromVerse(String text, Visitor<RuntimeException> vv, Hyper
vv.visitText("<");
text = text.substring(1);
} else if (text.startsWith("<i>")) {
text = convertFromVerse(text.substring(3), vv.visitFormattingInstruction(FormattingInstructionKind.ITALIC), hp, footnoteDB, vnums, nt);
text = convertFromVerse(text.substring(3), vv.visitFormattingInstruction(FormattingInstructionKind.ITALIC), hp, footnoteDB, vnums, nt, strongsPrefix);
if (!text.startsWith("</i>"))
System.out.println("WARNING: Unclosed <i> tag at: " + text);
else {
text = text.substring(4);
}
} else if (text.startsWith("<J>")) {
text = convertFromVerse(text.substring(3), vv.visitFormattingInstruction(FormattingInstructionKind.WORDS_OF_JESUS), hp, footnoteDB, vnums, nt);
text = convertFromVerse(text.substring(3), vv.visitFormattingInstruction(FormattingInstructionKind.WORDS_OF_JESUS), hp, footnoteDB, vnums, nt, strongsPrefix);
if (!text.startsWith("</J>"))
System.out.println("WARNING: Unclosed <J> tag at: " + text);
else {
text = text.substring(4);
}
} else if (text.startsWith("<e>")) {
text = convertFromVerse(text.substring(3), vv.visitFormattingInstruction(FormattingInstructionKind.BOLD), hp, footnoteDB, vnums, nt);
text = convertFromVerse(text.substring(3), vv.visitFormattingInstruction(FormattingInstructionKind.BOLD), hp, footnoteDB, vnums, nt, strongsPrefix);
if (!text.startsWith("</e>"))
System.out.println("WARNING: Unclosed <e> tag at: " + text);
else {
text = text.substring(4);
}
} else if (text.startsWith("<h>")) {
text = convertFromVerse(text.substring(3), vv.visitHeadline(1), hp, footnoteDB, vnums, nt);
text = convertFromVerse(text.substring(3), vv.visitHeadline(1), hp, footnoteDB, vnums, nt, strongsPrefix);
if (!text.startsWith("</h>"))
System.out.println("WARNING: Unclosed <e> tag at: " + text);
else {
Expand Down

3 comments on commit 3bbdf13

@Michahel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I experience a problem during the Building BibleMultiConverter SQLite Edition.

[INFO] Scanning for projects...
[INFO] 
[INFO] -------< biblemulticonverter:BibleMultiConverter-SQLiteEdition >--------
[INFO] Building BibleMultiConverter SQLite Edition 0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ BibleMultiConverter-SQLiteEdition ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ BibleMultiConverter-SQLiteEdition ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to C:\Proj\GitHub\BibleMultiConverter\biblemulticonverter-sqlite\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MyBibleZone.java:[468,56] cannot find symbol
  symbol:   method parseStrongs(java.lang.String,char,char[])
  location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MyBibleZone.java:[493,72] cannot find symbol
  symbol:   variable MORPH_REGEX
  location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MyBibleZone.java:[1128,65] cannot find symbol
  symbol:   method formatStrongs(boolean,int,char[],int[])
  location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MySword.java:[190,56] cannot find symbol
  symbol:   method parseStrongs(java.lang.String,char,char[])
  location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MySword.java:[201,72] cannot find symbol
  symbol:   variable MORPH_REGEX
  location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MySword.java:[544,63] cannot find symbol
  symbol:   method formatStrongs(boolean,int,char[],int[])
  location: class biblemulticonverter.data.Utils
[INFO] 6 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13.281 s
[INFO] Finished at: 2024-05-20T18:00:20+06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile (default-compile) on project BibleMultiConverter-SQLiteEdition: Compilation failure: Compilation failure: 
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MyBibleZone.java:[468,56] cannot find symbol
[ERROR]   symbol:   method parseStrongs(java.lang.String,char,char[])
[ERROR]   location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MyBibleZone.java:[493,72] cannot find symbol
[ERROR]   symbol:   variable MORPH_REGEX
[ERROR]   location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MyBibleZone.java:[1128,65] cannot find symbol
[ERROR]   symbol:   method formatStrongs(boolean,int,char[],int[])
[ERROR]   location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MySword.java:[190,56] cannot find symbol
[ERROR]   symbol:   method parseStrongs(java.lang.String,char,char[])
[ERROR]   location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MySword.java:[201,72] cannot find symbol
[ERROR]   symbol:   variable MORPH_REGEX
[ERROR]   location: class biblemulticonverter.data.Utils
[ERROR] /C:/Proj/GitHub/BibleMultiConverter/biblemulticonverter-sqlite/src/main/java/biblemulticonverter/sqlite/format/MySword.java:[544,63] cannot find symbol
[ERROR]   symbol:   method formatStrongs(boolean,int,char[],int[])
[ERROR]   location: class biblemulticonverter.data.Utils
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

@schierlm
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably have a cached version of either "BibleMultiConverter" or "BibleMultiConverter-schemas" dependency. You need to rebuild these first. Or build the whole parent project. Or pick the nightly build from CI.

@Michahel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works fine for me.

Please sign in to comment.