Skip to content

Commit

Permalink
Fix the count of vocab in verse vocab
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksptang committed Jul 12, 2024
1 parent 9597dc1 commit 9bc0ae6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void addToRefArray(TreeMap<Short, String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ else if (customFN.containsKey(curOrdinal))
final Book preferredCountBook = getPreferredCountBook(this.isOT);
final List<Element> elements = JSwordUtils.getOsisElements(new BookData(preferredCountBook, key));
Set<String> strongAlreadyIncluded = new HashSet<String>();
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);
Expand All @@ -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) {
Expand Down Expand Up @@ -184,7 +185,7 @@ public PassageStat calculateStrongArrayCounts(final String version, PassageStat
Map<String, Integer[]> 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()});
Expand Down Expand Up @@ -218,20 +219,20 @@ 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();
final IndexSearcher is = jSwordSearchService.getIndexSearcher(
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<String, BookAndBibleCount> strong : this.allStrongs.entrySet()) {
Expand Down

0 comments on commit 9bc0ae6

Please sign in to comment.