From 9bc0ae69d8fcb3a95b7309e437e91e613e12e732 Mon Sep 17 00:00:00 2001 From: Patrick Tang <36460266+patricksptang@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:56:55 -0700 Subject: [PATCH] Fix the count of vocab in verse vocab --- .../impl/StrongAugmentationServiceImpl.java | 2 +- .../helpers/JSwordStrongNumberHelper.java | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/StrongAugmentationServiceImpl.java b/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/StrongAugmentationServiceImpl.java index f058ededa9..521e2bb87c 100644 --- a/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/StrongAugmentationServiceImpl.java +++ b/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/StrongAugmentationServiceImpl.java @@ -175,7 +175,7 @@ private void addToRefArray(TreeMap ordinalStrong, final Versifica System.out.println("Cannot find ordinal for " + mainRef); continue; // cannot process it because it cannot find the ordinal. } - if ((!versification.getName().equals("Leningrad")) && (refOrdinal > NT_OFFSET)) + if ((!versification.getName().equals("MT")) && (refOrdinal > NT_OFFSET)) refOrdinal -= NT_OFFSET; curRefOrdinalAndOccurrences.ordinal = refOrdinal; ordinalOccurrencesArray[index] = curRefOrdinalAndOccurrences; diff --git a/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java b/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java index d874267bdf..1d376872f2 100644 --- a/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java +++ b/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java @@ -135,10 +135,11 @@ else if (customFN.containsKey(curOrdinal)) final Book preferredCountBook = getPreferredCountBook(this.isOT); final List elements = JSwordUtils.getOsisElements(new BookData(preferredCountBook, key)); Set strongAlreadyIncluded = new HashSet(); + String verseRef = ""; for (final Element e : elements) { if (elements.size() == 1) // If it is from verseVocabuary, it will only has one morphology allMorph = OSISUtil.getMorphologiesWithStrong(e); - final String verseRef = e.getAttributeValue(OSISUtil.OSIS_ATTR_OSISID); + verseRef = e.getAttributeValue(OSISUtil.OSIS_ATTR_OSISID); final String strongsNumbers = OSISUtil.getStrongsNumbers(e); if (StringUtils.isBlank(strongsNumbers)) { LOG.warn("Attempting to search for 'no strongs' in verse [{}]", verseRef); @@ -156,7 +157,7 @@ else if (customFN.containsKey(curOrdinal)) readDataFromLexicon(this.definitions, verseRef, String.join(" ", uniqueStrong), userLanguage); } // now get counts in the relevant portion of text - applySearchCounts(getBookFromKey(key)); + applySearchCounts(getBookFromKey(key), verseRef); } catch (final NoSuchKeyException ex) { LOG.warn("Unable to enhance verse numbers.", ex); } catch (final BookException ex) { @@ -184,7 +185,7 @@ public PassageStat calculateStrongArrayCounts(final String version, PassageStat Map temp = stat.getStats(); temp.forEach((strongNum, feq) -> this.allStrongs.put(strongNum, new BookAndBibleCount())); // now get counts in the relevant portion of text - applySearchCounts(getBookFromKey(key)); + applySearchCounts(getBookFromKey(key), ""); temp.forEach((strongNum, freq) -> { BookAndBibleCount bBCount = this.allStrongs.get(strongNum); result.put(strongNum, new Integer[]{freq[0], bBCount.getBook(), bBCount.getBible()}); @@ -218,7 +219,7 @@ public static class detailLexClass { // used by ObjectMapper to convert JSON in * * @param bookName the book name */ - private void applySearchCounts(final String bookName) { + private void applySearchCounts(final String bookName, final String curOsisID) { try { ObjectMapper mapper = new ObjectMapper(); @@ -226,12 +227,12 @@ private void applySearchCounts(final String bookName) { this.isOT ? STRONG_OT_VERSION_BOOK.getInitials() : STRONG_NT_VERSION_BOOK.getInitials()); final TermDocs termDocs = is.getIndexReader().termDocs(); ArrayList lexiconSuggestions = null; - if (this.verseStrongs != null) { - lexiconSuggestions = (ArrayList) this.verseStrongs.get(this.reference.getOsisID()); - if ((lexiconSuggestions == null) && (this.verseStrongs.size() == 1)) { - System.out.println("Do not match: " + this.verseStrongs.keySet() + " " + this.reference.getOsisID()); - lexiconSuggestions = (ArrayList) this.verseStrongs.get(this.verseStrongs.keySet().toArray()[0]); - } + if ((this.verseStrongs != null) && (!curOsisID.equals(""))) { + lexiconSuggestions = (ArrayList) this.verseStrongs.get(curOsisID); +// if ((lexiconSuggestions == null) && (this.verseStrongs.size() == 1)) { +// System.out.println("Do not match: " + this.verseStrongs.keySet() + " " + this.reference.getOsisID()); +// lexiconSuggestions = (ArrayList) this.verseStrongs.get(this.verseStrongs.keySet().toArray()[0]); +// } } final int sizeOfLexiconSuggestion = (lexiconSuggestions == null) ? 0 : lexiconSuggestions.size(); for (final Entry strong : this.allStrongs.entrySet()) {