def demo(): """ Demonstrate how some of the above classes can be used. """ from VerseReferences import SimpleVerseKey if BibleOrgSysGlobals.verbosityLevel > 0: print(ProgNameVersion) testRefs = ( ('GEN', '1', '1'), ('JER', '33', '3'), ('MAL', '4', '6'), ('MAT', '1', '1'), ('JHN', '3', '16'), ('JDE', '1', '14'), ('REV', '22', '21'), ) if 1: # Test the GenericOnlineBible class print() dbpBible1 = GenericOnlineBible() print(dbpBible1) for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) print(verseKey) dbpBible1.cacheVerse(verseKey, [f"Verse text for {verseKey}"]) print(f" Cache length: {len(dbpBible1.cache)}") print(" ", dbpBible1.getCachedVerseDataList(verseKey)) # Now test the GenericOnlineBible class caching print() for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) print(verseKey, "cached") print(" ", dbpBible1.getCachedVerseDataList(verseKey))
def demo(): """ Main program to handle command line parameters and then run what they want. """ if BibleOrgSysGlobals.verbosityLevel > 0: print(ProgNameVersion) fileFolder = "../../../ExternalPrograms/morphgnt/sblgnt/" # Demonstrate the Greek NT class if BibleOrgSysGlobals.verbosityLevel > 1: print("\nDemonstrating the Greek NT class…") testReference = SimpleVerseKey('MAT', '1', '1') #print( testFolder, testReference ) gNT = GreekNT(fileFolder) # Load and process the XML gNT.loadBooks() #gNT.analyzeWords() # File and sort the Greek words for later use print(gNT) # Just print a summary print() print(testReference, gNT.getVerseDataList(testReference)) print() for testReference in SimpleVerseKey('MAT', '28', '1'), SimpleVerseKey( 'MRK', '2', '2'), SimpleVerseKey('REV', '21', '21'): verseText = gNT.getVerseText(testReference) print(testReference, verseText) print()
def updateGenericGlossingReferences( self ): """ Go through the entire WLC and check for words that we already have a gloss for and update the reference fields. """ from VerseReferences import SimpleVerseKey if BibleOrgSysGlobals.verbosityLevel > 1: print( _("Updating references for WLC generic glosses…") ) self.loadBooks() numRefsAdded = 0 for BBB,bookObject in self.books.items(): # These don't seem to be in order! # The following few lines show a way to iterate through all verses # (assuming all chapters are full of verses -- not sure how it handles bridged verses) C = V = 1 #print( BBB ) while True: currentVerseKey = SimpleVerseKey( BBB, C, V ) try: verseDataList, context = self.getContextVerseData( currentVerseKey ) except KeyError: C, V = C+1, 1 currentVerseKey = SimpleVerseKey( BBB, C, V ) try: verseDataList, context = self.getContextVerseData( currentVerseKey ) except KeyError: break # start next book #print( "context", context ) #print( "verseDataList", verseDataList ) for verseDataEntry in verseDataList: #print( "verseDataEntry", verseDataEntry ) assert isinstance( verseDataEntry, InternalBibleEntry ) marker, cleanText, extras = verseDataEntry.getMarker(), verseDataEntry.getCleanText(), verseDataEntry.getExtras() adjustedText, originalText = verseDataEntry.getAdjustedText(), verseDataEntry.getOriginalText() if marker in ('v~','p~'): verseDictList = self.getVerseDictList( verseDataEntry, currentVerseKey ) #print( currentVerseKey.getShortText(), "verseDictList", verseDictList ) for j,verseDict in enumerate( verseDictList ): # each verseDict represents one word or token fullRefTuple = (BBB,str(C),str(V),str(j+1)) #print( fullRefTuple, verseDict ) word = verseDict['word'] normalizedHebrewWord = self.removeCantillationMarks( word, removeMetegOrSiluq=True ) \ .replace( ORIGINAL_MORPHEME_BREAK_CHAR, OUR_MORPHEME_BREAK_CHAR ) #print( ' ', len(word), repr(word), len(normalizedHebrewWord), repr(normalizedHebrewWord) ) genericGloss,genericReferencesList,specificReferencesDict = self.glossingDict[normalizedHebrewWord] \ if normalizedHebrewWord in self.glossingDict else ('',[],{}) #if genericGloss: print( fullRefTuple, repr(genericGloss) ) if genericGloss and genericGloss not in '־׃ספ-' and fullRefTuple not in genericReferencesList: #print( " Adding {}".format( fullRefTuple ) ) self.addNewGenericGlossingReference( normalizedHebrewWord, fullRefTuple ) numRefsAdded += 1 V = V + 1 if BibleOrgSysGlobals.verbosityLevel > 0: print( " {} new references added ({} words in dict)".format( numRefsAdded, len(self.glossingDict) ) )
def mapParallelVerseKey( forGroupCode, mainVerseKey ): """ Returns the verse key for synoptic references in the NT, etc. Returns None if we don't have a mapping. """ if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( exp("mapParallelVerseKey( {}, {} )").format( forGroupCode, mainVerseKey.getShortText() ) ) groupIndex = BIBLE_GROUP_CODES.index( forGroupCode ) - 1 parallelVerseKeyDict = { SimpleVerseKey('MAT','3','13'): (SimpleVerseKey('MRK','1','9'), SimpleVerseKey('LUK','3','21'), SimpleVerseKey('JHN','1','31') ) } if mainVerseKey in parallelVerseKeyDict: if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( ' returning {}'.format( parallelVerseKeyDict[mainVerseKey][groupIndex].getShortText() ) ) return parallelVerseKeyDict[mainVerseKey][groupIndex]
def mapReferenceVerseKey( mainVerseKey ): """ Returns the verse key for OT references in the NT (and vv), etc. Returns None if we don't have a mapping. """ if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( exp("mapReferenceVerseKey( {} )").format( mainVerseKey.getShortText() ) ) # A (temporary) dictionary containing NT references to OT REFERENCE_VERSE_KEY_DICT = { SimpleVerseKey('MAT','2','18'): SimpleVerseKey('JER','31','15'), SimpleVerseKey('MAT','3','3'): SimpleVerseKey('ISA','40','3'), } if mainVerseKey in REFERENCE_VERSE_KEY_DICT: if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( ' returning {}'.format( REFERENCE_VERSE_KEY_DICT[mainVerseKey].getShortText() ) ) return REFERENCE_VERSE_KEY_DICT[mainVerseKey]
def demo(): """ Main program to handle command line parameters and then run what they want. """ from VerseReferences import SimpleVerseKey if BibleOrgSysGlobals.verbosityLevel > 1: print(ProgNameVersion) # Demo the BibleReferencesLinks object brl = BibleReferencesLinks().loadData( ) # Doesn't reload the XML unnecessarily :) print(brl) # Just print a summary testKeys = ( 'MAT_1:23', 'MAT_3:12', 'MRK_7:7', 'ACT_7:8', 'ISA_7:14', ) print("\nTest full passage list...") for verseReferenceString in testKeys: svk = SimpleVerseKey(verseReferenceString) print(svk.getShortText()) #print( svk, brl.getFullRelatedPassagesList( svk ) ) relatedPassageList = brl.getFullRelatedPassagesList(svk) if relatedPassageList: for relatedPassage in relatedPassageList: #print( ' ', relatedPassage ) sourceReference, sourceComponent, parsedSourceReference, actualLinksList = relatedPassage print(' ', sourceReference) for actualLink in actualLinksList: #print( ' ', actualLink ) targetReference, targetComponent, parsedTargetReference, linkType = actualLink print(' ', linkType, targetReference) print("\nTest passage list...") for verseReferenceString in testKeys: svk = SimpleVerseKey(verseReferenceString) print(svk.getVerseKeyText(), brl.getRelatedPassagesList(svk))
def demo(): """ Demonstrate how some of the above classes can be used. """ if Globals.verbosityLevel > 0: print(ProgNameVersion) if 1: # Test the DBPBibles class print() dbpBibles = DBPBibles() print(dbpBibles) #if 0: #for someName in dbpBibles.volumeNameList: #if 'English' in someName: print( "English:", someName, dbpBibles.volumeNameList[someName] ) print("English search", dbpBibles.searchNames("English")) print("MS search", dbpBibles.searchNames("Salug")) if 1: # Test the DBPBible class print() dbpBible1 = DBPBible("ENGESV") print(dbpBible1) for verseKey in ( SimpleVerseKey('GEN', '1', '1'), SimpleVerseKey('MAT', '1', '1'), SimpleVerseKey('JHN', '3', '16'), ): print(verseKey) print(dbpBible1.getVerseData(verseKey)) if 1: # Test the DBPBible class print() dbpBible2 = DBPBible("MBTWBT") print(dbpBible2) for verseKey in ( SimpleVerseKey('MAT', '1', '1'), SimpleVerseKey('JHN', '3', '16'), ): print(verseKey) print(dbpBible2.getVerseData(verseKey))
def updateShownBCV(self, newReferenceVerseKey, originator=None): """ """ if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( "BibleReferenceCollectionWindow.updateShownBCV( {}, {} ) for". format(newReferenceVerseKey, originator), self.moduleID) assert isinstance(newReferenceVerseKey, SimpleVerseKey) refBBB, refC, refV, refS = newReferenceVerseKey.getBCVS() BBB, C, V, S = self.BibleOrganisationalSystem.convertFromReferenceVersification( refBBB, refC, refV, refS) newVerseKey = SimpleVerseKey(BBB, C, V, S) self.updateShownReferences(mapReferencesVerseKey(newVerseKey))
def demo(): """ Main program to handle command line parameters and then run what they want. """ if BibleOrgSysGlobals.verbosityLevel > 0: print(ProgNameVersion) from VerseReferences import SimpleVerseKey # Demonstrate the Hebrew WLC class #testFile = "../morphhb/wlc/Ruth.xml" # Hebrew Ruth testFile = "../morphhb/wlc/Dan.xml" # Hebrew Daniel testReference = ('DAN', '1', '5') testKey = SimpleVerseKey(testReference[0], testReference[1], testReference[2]) if BibleOrgSysGlobals.verbosityLevel > 1: print("\nDemonstrating the Hebrew WLC class...") #print( testFile, testReference ) wlc = HebrewWLC(testFile) wlc.load() # Load and process the XML print(wlc) # Just print a summary print() print(wlc.getVerseData(testKey)) print() verseText = wlc.getVerseText(testKey) wlc.currentText = verseText print("These all display left-to-right in the terminal unfortunately :-(") print(verseText) verseText = wlc.removeMorphemeBreaks() print() print(verseText) verseText = wlc.removeCantillationMarks() print() print(verseText) consonantalVerseText = wlc.removeVowelPointing() print() print(consonantalVerseText) print()
def updateShownReferences(self, newReferenceObject): """ Updates self in various ways depending on the contextViewMode held by the enclosing window. The new verse references are in the reference versification system in one of these objects: SimpleVerseKey (accepts 'GEN_1:1' or 'GEN','1','1') SimpleVersesKey (accepts 'MAT_6:1,4') VerseRangeKey (accepts 'JNA_2:1-7') Leaves the textbox in the disabled state. """ if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( "BibleReferenceBox.updateShownReferences( {} ) for {}".format( newReferenceObject, self.internalBible.getAName())) assert isinstance( newReferenceObject, SimpleVerseKey) or isinstance( newReferenceObject, SimpleVersesKey) or isinstance( newReferenceObject, VerseRangeKey) for j, referenceVerse in enumerate(newReferenceObject): #print( " refVerse", j, referenceVerse ) assert isinstance(referenceVerse, SimpleVerseKey) refBBB, refC, refV, refS = referenceVerse.getBCVS() BBB, C, V, S = self.BibleOrganisationalSystem.convertFromReferenceVersification( refBBB, refC, refV, refS) newVerseKey = SimpleVerseKey(BBB, C, V, S) #print( " newVK", newVerseKey ) # Set firstFlag as False (rather than j==0) so don't get context displayed self.displayAppendVerse(False, newVerseKey, self.getCachedVerseData(newVerseKey), lastFlag=False) self.textBox.configure(state=tk.DISABLED) # Don't allow editing
def findCurrentSection( currentVerseKey, getNumChapters, getNumVerses, getVerseData ): """ Given the current verseKey and functions to find the number of chapters and verses in the book and a function to get verse data (probably cached), find the beginning and end of the current section. Returns the verseKey for the start of the section and for the end of the section -- well actually the start of the next section. If no sections are found, it goes a maximum of one chapter back or one chapter forward. """ if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( exp("findCurrentSection( {}, … )").format( currentVerseKey.getShortText() ) ) def sectionFoundIn( verseData ): """ Given some verse data (a string or an InternalBibleEntryList returns True or False whether a section heading is found in it """ if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print( exp("sectionFoundIn( {!r} )").format( verseData ) ) if verseData is None: return False elif isinstance( verseData, str ): #print( " It's a string!" ) if '\\s ' in thisVerseData or '\\s1' in thisVerseData \ or '\\s2' in thisVerseData or '\\s3' in thisVerseData: return True elif isinstance( verseData, tuple ): #print( " It's an InternalBibleEntryList!" ) assert len(verseData) == 2 verseDataList, context = verseData #print( ' dataList', repr(verseDataList) ) #print( ' context', repr(context) ) for verseDataEntry in verseDataList: if isinstance( verseDataEntry, InternalBibleEntry ): marker, cleanText = verseDataEntry.getMarker(), verseDataEntry.getCleanText() elif isinstance( verseDataEntry, tuple ): marker, cleanText = verseDataEntry[0], verseDataEntry[3] elif isinstance( verseDataEntry, str ): if verseDataEntry=='': continue verseDataEntry += '\n' if verseDataEntry[0]=='\\': marker = '' for char in verseDataEntry[1:]: if char!='¬' and not char.isalnum(): break marker += char cleanText = verseDataEntry[len(marker)+1:].lstrip() else: marker, cleanText = None, verseDataEntry elif BibleOrgSysGlobals.debugFlag: halt if marker in ( 's','s1','s2','s3','s4' ): return True else: print( 'Ooops', repr(verseData) ) print( verseData.__type__ ) halt # Programming error return False # end of sectionFoundIn # Start of main section of findCurrentSection BBB, C, V = currentVerseKey.getBCV() intC, intV = currentVerseKey.getChapterNumberInt(), currentVerseKey.getVerseNumberInt() #print( 'fCS at', BBB, C, intC, V, intV ) # First let's find the beginning of the section # which could be in the current verse/chapter, # or in the previous chapter (at most we assume) #print( 'fCS finding start…' ) firstC = max( intC-1, 0 ) found = False for thisC in reversed( range( firstC, intC+1 ) ): # Look backwards numVerses = getNumVerses( BBB, thisC ) startV, endV = 0, numVerses if thisC == intC: endV = min( intV, numVerses ) for thisV in reversed( range( startV, endV+1 ) ): thisVerseKey = SimpleVerseKey( BBB, thisC, thisV ) thisVerseData = getVerseData( thisVerseKey ) if debuggingThisModule: ( ' ', thisC, thisV, repr(thisVerseData) ) if sectionFoundIn( thisVerseData ): found = thisC, thisV; break if found: break if not found: found = firstC, 0 startKey = SimpleVerseKey( BBB, found[0], found[1] ) # Now let's find the end of the section # which could be in the current chapter, or in the next chapter (at most we assume) #print( 'fCS finding end…' ) lastC = min( intC+1, getNumChapters( BBB ) ) found = False for thisC in range( intC, lastC+1 ): numVerses = getNumVerses( BBB, thisC ) startV, endV = 0, numVerses if thisC == intC: startV = min( intV+1, numVerses ) for thisV in range( startV, endV+1 ): thisVerseKey = SimpleVerseKey( BBB, thisC, thisV ) thisVerseData = getVerseData( thisVerseKey ) if debuggingThisModule: ( ' ', thisC, thisV, repr(thisVerseData) ) if sectionFoundIn( thisVerseData ): found = thisC, thisV; break if found: break if not found: found = lastC, numVerses endKey = SimpleVerseKey( BBB, found[0], found[1] ) #print( "fCS returning", startKey.getShortText(), endKey.getShortText() ) return startKey, endKey
def demo(): """ Demonstrate how some of the above classes can be used. """ from VerseReferences import SimpleVerseKey if BibleOrgSysGlobals.verbosityLevel > 0: print(ProgNameVersion, end='\n\n') if 1: # Test the DCSBibles class dcsBibles = DCSBibles() if BibleOrgSysGlobals.verbosityLevel > 0: print(dcsBibles, end='\n\n') #dcsBibles.load() # takes a minute #print( dcsBibles ) if 1: dcsBibles.fetchAllBibles() if BibleOrgSysGlobals.verbosityLevel > 0: print("Bible list ({}):".format(len(dcsBibles.BibleList))) for j, BibleDict in enumerate(dcsBibles.BibleList): ownerName = BibleDict['owner']['full_name'] if not ownerName: ownerName = BibleDict['owner']['username'] if BibleOrgSysGlobals.verbosityLevel > 1: print( f" Entry {j:3} '{BibleDict['name']}' '{ownerName}'") testRefs = ( ('GEN', '1', '1'), ('GEN', '2', '2'), ('JER', '33', '3'), ('MAL', '4', '6'), ('MAT', '1', '1'), ('JHN', '3', '16'), ('JDE', '1', '14'), ('REV', '22', '21'), ) if 1: # Test the DCSBible class with the ULT downloadAllBooks = True if BibleOrgSysGlobals.verbosityLevel > 0: print() searchResult = dcsBibles.searchRepos('unfoldingWord', 'en_ult') #print( 'searchResult', searchResult ) if searchResult and isinstance(searchResult, dict): dcsBible1 = DCSBible(searchResult, downloadAllBooks=downloadAllBooks) try: dcsBible1.preload() except FileNotFoundError: assert downloadAllBooks == False if BibleOrgSysGlobals.verbosityLevel > 1: print(dcsBible1, end='\n\n') for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) if BibleOrgSysGlobals.verbosityLevel > 0: print(verseKey) print(" ", dcsBible1.getVerseDataList(verseKey)) elif BibleOrgSysGlobals.verbosityLevel > 0: print(f"Unexpected search result: {searchResult}") if 1: # Test the DCSBible class with the UST downloadAllBooks = False if BibleOrgSysGlobals.verbosityLevel > 0: print() searchResult = dcsBibles.searchRepos('unfoldingWord', 'en_ust') #print( 'searchResult', searchResult ) if searchResult and isinstance(searchResult, dict): dcsBible1 = DCSBible(searchResult, downloadAllBooks=downloadAllBooks) try: dcsBible1.preload() except FileNotFoundError: assert downloadAllBooks == False if BibleOrgSysGlobals.verbosityLevel > 1: print(dcsBible1, end='\n\n') for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) if BibleOrgSysGlobals.verbosityLevel > 0: print(verseKey) print(" ", dcsBible1.getVerseDataList(verseKey)) elif BibleOrgSysGlobals.verbosityLevel > 0: print(f"Unexpected search result: {searchResult}")
def importDataToPython(self): """ Loads (and pivots) the data (not including the header) into suitable Python containers to use in a Python program. (Of course, you can just use the elementTree in self._XMLtree if you prefer.) """ def makeList(parameter1, parameter2): """ Returns a list containing all parameters. Parameter1 may already be a list. """ if isinstance(parameter1, list): #assert( parameter2 not in parameter1 ) parameter1.append(parameter2) return parameter1 else: return [parameter1, parameter2] # end of makeList assert (self._XMLtree) if self.__DataList: # We've already done an import/restructuring -- no need to repeat it return self.__DataList, self.__DataDict # We'll create a number of dictionaries with different elements as the key rawRefLinkList = [] actualLinkCount = 0 for element in self._XMLtree: #print( BibleOrgSysGlobals.elementStr( element ) ) # Get these first for helpful error messages sourceReference = element.find('sourceReference').text sourceComponent = element.find('sourceComponent').text assert (sourceComponent in ( 'Section', 'Verses', 'Verse', )) BibleOrgSysGlobals.checkXMLNoText(element, sourceReference, 'kls1') BibleOrgSysGlobals.checkXMLNoAttributes(element, sourceReference, 'kd21') BibleOrgSysGlobals.checkXMLNoTail(element, sourceReference, 'so20') actualRawLinksList = [] for subelement in element: #print( BibleOrgSysGlobals.elementStr( subelement ) ) if subelement.tag in ( 'sourceReference', 'sourceComponent', ): # already processed these BibleOrgSysGlobals.checkXMLNoAttributes( subelement, sourceReference, 'ls12') BibleOrgSysGlobals.checkXMLNoSubelements( subelement, sourceReference, 'ks02') BibleOrgSysGlobals.checkXMLNoTail(subelement, sourceReference, 'sqw1') elif subelement.tag == 'BibleReferenceLink': BibleOrgSysGlobals.checkXMLNoText(subelement, sourceReference, 'haw9') BibleOrgSysGlobals.checkXMLNoAttributes( subelement, sourceReference, 'hs19') BibleOrgSysGlobals.checkXMLNoTail(subelement, sourceReference, 'jsd9') targetReference = subelement.find('targetReference').text targetComponent = subelement.find('targetComponent').text assert (targetComponent in ( 'Section', 'Verses', 'Verse', )) linkType = subelement.find('linkType').text assert (linkType in ( 'TSK', 'QuotedOTReference', 'AlludedOTReference', 'PossibleOTReference', )) actualRawLinksList.append(( targetReference, targetComponent, linkType, )) actualLinkCount += 1 rawRefLinkList.append(( sourceReference, sourceComponent, actualRawLinksList, )) if BibleOrgSysGlobals.verbosityLevel > 1: print(" {} raw links loaded (with {} actual raw link entries)". format(len(rawRefLinkList), actualLinkCount)) myRefLinkList = [] actualLinkCount = 0 BOS = BibleOrganizationalSystem("GENERIC-KJV-66-ENG") for j, (sourceReference, sourceComponent, actualRawLinksList) in enumerate(rawRefLinkList): # Just do some testing first if sourceComponent == 'Verse': x = SimpleVerseKey(sourceReference) else: flag = False try: x = SimpleVerseKey(sourceReference, ignoreParseErrors=True) flag = True except TypeError: pass # This should happen coz it should fail the SVK if flag: logging.error("{} {!r} failed!".format( sourceComponent, sourceReference)) raise TypeError # Now do the actual parsing parsedSourceReference = FlexibleVersesKey(sourceReference) if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print(j, sourceComponent, sourceReference, parsedSourceReference) #assert( parsedSourceReference.getShortText().replace(' ','_') == sourceReference ) actualLinksList = [] for k, (targetReference, targetComponent, linkType) in enumerate(actualRawLinksList): # Just do some testing first if targetComponent == 'Verse': x = SimpleVerseKey(targetReference) else: flag = False try: x = SimpleVerseKey(targetReference, ignoreParseErrors=True) flag = True except TypeError: pass # This should happen coz it should fail the SVK if flag: logging.error("{} {!r} failed!".format( targetComponent, targetReference)) raise TypeError # Now do the actual parsing try: parsedTargetReference = FlexibleVersesKey(targetReference) except TypeError: print( " Temporarily ignored {!r} (TypeError from FlexibleVersesKey)" .format(targetReference)) parsedTargetReference = None if BibleOrgSysGlobals.debugFlag and debuggingThisModule: print(' ', targetComponent, targetReference, parsedTargetReference) #assert( parsedTargetReference.getShortText().replace(' ','_',1) == targetReference ) actualLinksList.append(( targetReference, targetComponent, parsedTargetReference, linkType, )) actualLinkCount += 1 myRefLinkList.append(( sourceReference, sourceComponent, parsedSourceReference, actualLinksList, )) if BibleOrgSysGlobals.verbosityLevel > 1: print(" {} links processed (with {} actual link entries)".format( len(rawRefLinkList), actualLinkCount)) #print( myRefLinkList ); halt self.__DataList = myRefLinkList # Now put it into my dictionaries for easy access # This part should be customized or added to for however you need to process the data # Create a link dictionary (by verse key) myRefLinkDict = {} for sourceReference, sourceComponent, parsedSourceReference, actualLinksList in myRefLinkList: #print( sourceReference, sourceComponent, parsedSourceReference ) #print( sourceReference, sourceComponent, parsedSourceReference, actualLinksList ) for verseRef in parsedSourceReference.getIncludedVerses(): #print( verseRef ) assert (isinstance(verseRef, SimpleVerseKey)) if verseRef not in myRefLinkDict: myRefLinkDict[verseRef] = [] myRefLinkDict[verseRef].append(( sourceReference, sourceComponent, parsedSourceReference, actualLinksList, )) #print( myRefLinkDict ); halt originalLinks = len(myRefLinkDict) print( " {} verse links added to dictionary (includes filling out spans)" .format(originalLinks)) #print( myRefLinkDict ); halt # Create a reversed link dictionary (by verse key) for sourceReference, sourceComponent, parsedSourceReference, actualLinksList in myRefLinkList: #print( sourceReference, sourceComponent, parsedSourceReference ) #print( sourceReference, sourceComponent, parsedSourceReference, actualLinksList ) for targetReference, targetComponent, parsedTargetReference, linkType in actualLinksList: if parsedTargetReference is not None: for verseRef in parsedTargetReference.getIncludedVerses(): #print( verseRef ) assert (isinstance(verseRef, SimpleVerseKey)) if linkType == 'TSK': reverseLinkType = 'TSKQuoted' elif linkType == 'QuotedOTReference': reverseLinkType = 'OTReferenceQuoted' elif linkType == 'AlludedOTReference': reverseLinkType = 'OTReferenceAlluded' elif linkType == 'PossibleOTReference': reverseLinkType = 'OTReferencePossible' else: halt # Have a new linkType! if verseRef not in myRefLinkDict: myRefLinkDict[verseRef] = [] myRefLinkDict[verseRef].append( (targetReference, targetComponent, parsedTargetReference, [ (sourceReference, sourceComponent, parsedSourceReference, reverseLinkType) ])) #print( myRefLinkDict ); halt totalLinks = len(myRefLinkDict) reverseLinks = totalLinks - originalLinks print(" {} reverse links added to dictionary to give {} total".format( reverseLinks, totalLinks)) #print( myRefLinkDict ); halt self.__DataDict = myRefLinkDict # Let's find the most number of references for a verse mostReferences = totalReferences = 0 for verseRef, entryList in self.__DataDict.items(): numRefs = len(entryList) if numRefs > mostReferences: mostReferences, mostVerseRef = numRefs, verseRef totalReferences += numRefs print(" {} maximum links for any one reference ({})".format( mostReferences, mostVerseRef.getShortText())) print(" {} total links for all references".format(totalReferences)) return self.__DataList, self.__DataDict
def demo(): """ Demonstrate how some of the above classes can be used. """ if BibleOrgSysGlobals.verbosityLevel > 0: print(ProgNameVersion) if 1: # Test the DBPBibles class print() dbpBibles = DBPBibles() print(dbpBibles) #dbpBibles.load() # takes a minute #print( dbpBibles ) if 0: dbpBibles.fetchAllLanguages() print("\nLanguage list ({}):".format(len(dbpBibles.languageList))) for j, lgDict in enumerate(dbpBibles.languageList): print('Lg', j, repr(lgDict)) if 0: dbpBibles.fetchAllVersions() print("\nVersion list ({}):".format(len(dbpBibles.versionList))) for j, verDict in enumerate(dbpBibles.versionList): print('Ver', j, repr(verDict)) if 0: dbpBibles.fetchAllVolumes() print("\nVolume list ({}):".format(len(dbpBibles.volumeList))) for j, volDict in enumerate(dbpBibles.volumeList): print(' ', j, repr(volDict)) print("393", dbpBibles.volumeList[393]) print("394", dbpBibles.volumeList[394]) print("395", dbpBibles.volumeList[395]) if 0: dbpBibles.fetchTextVolumes() print("\nVolume name dict ({}):".format( len(dbpBibles.volumeNameDict))) for j, someName in enumerate(dbpBibles.volumeNameDict): #if 'English' in someName: #print( "English:", repr(someName), repr(dbpBibles.volumeNameDict[someName]) ) print(j, repr(someName), repr(dbpBibles.volumeNameDict[someName])) #if 'English' in someName: #print( " English:", repr(someName), repr(dbpBibles.volumeNameDict[someName]) ) print("English search", dbpBibles.searchNames("English")) print("MS search", dbpBibles.searchNames("Salug")) if 1: dbpBibles.fetchAllEnglishTextVolumes() print("\nEnglish volume name dict ({}):".format( len(dbpBibles.EnglishVolumeNameDict))) for j, someName in enumerate(dbpBibles.EnglishVolumeNameDict): #if 'English' in someName: #print( "English:", repr(someName), repr(dbpBibles.EnglishVolumeNameDict[someName]) ) print(" {}/ {!r} {!r}".format( j, someName, dbpBibles.EnglishVolumeNameDict[someName])) #if 'English' in someName: #print( " English:", repr(someName), repr(dbpBibles.EnglishVolumeNameDict[someName]) ) testRefs = ( ('GEN', '1', '1'), ('JER', '33', '3'), ('MAL', '4', '6'), ('MAT', '1', '1'), ('JHN', '3', '16'), ('JDE', '1', '14'), ('REV', '22', '21'), ) if 1: # Test the DBPBible class with the ESV print() dbpBible1 = DBPBible("ENGESV") print(dbpBible1) for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) print(verseKey) print(" ", dbpBible1.getVerseData(verseKey)) # Now test the DBPBible class caching for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) print(verseKey, "cached") print(" ", dbpBible1.getVerseData(verseKey)) if 1: # Test the DBPBible class with the MS print() dbpBible2 = DBPBible("MBTWBT") print(dbpBible2) for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) print(verseKey) print(" ", dbpBible2.getVerseData(verseKey))
def demo(): """ Main program to handle command line parameters and then run what they want. """ from VerseReferences import SimpleVerseKey from InternalBibleInternals import InternalBibleEntryList, InternalBibleEntry if BibleOrgSysGlobals.verbosityLevel > 0: print( ProgNameVersion ) # Demonstrate the Hebrew WLC class standardTestReferences = ('GEN', '1', '1'), ('SA1','1','1'), ('DAN', '1', '5') if 1: # Test one book #testFile = "../morphhb/wlc/Ruth.xml" # Hebrew Ruth testFile = '../morphhb/wlc/Dan.xml' # Hebrew Daniel if BibleOrgSysGlobals.verbosityLevel > 0: print( "\nA/ Demonstrating the Hebrew WLC class (one book only)…" ) #print( testFile ) wlc = OSISHebrewWLCBible( testFile ) wlc.load() # Load and process the XML book if BibleOrgSysGlobals.verbosityLevel > 0: print( wlc ) # Just print a summary print() for testReference in standardTestReferences: testKey = SimpleVerseKey( testReference[0], testReference[1], testReference[2] ) verseDataList = wlc.getVerseDataList( testKey ) if verseDataList is not None: assert isinstance( verseDataList, InternalBibleEntryList ) if BibleOrgSysGlobals.verbosityLevel > 1: print( testKey ) print( "VDL", verseDataList ) print() verseText = wlc.getVerseText( testKey ) wlc.currentText = verseText if BibleOrgSysGlobals.verbosityLevel > 0: #print( "These all display left-to-right in the terminal unfortunately :-(" ) print( verseText ) verseText = wlc.removeMorphemeBreaks() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without morpheme breaks" ) print( verseText ) verseText = wlc.removeCantillationMarks() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without cantillation marks" ) print( verseText ) consonantalVerseText = wlc.removeVowelPointing() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without vowel pointing" ) print( consonantalVerseText ) print() if 1: # Load all books and test testFolder = DEFAULT_OSIS_WLC_FILEPATH # Hebrew if BibleOrgSysGlobals.verbosityLevel > 0: print( "\nB/ Demonstrating the Hebrew WLC class (whole Bible)…" ) #print( testFolder ) wlc = OSISHebrewWLCBible( testFolder ) wlc.loadBooks() # Load and process the XML files if BibleOrgSysGlobals.verbosityLevel > 0: print( wlc ) # Just print a summary print() for testReference in standardTestReferences: testKey = SimpleVerseKey( testReference[0], testReference[1], testReference[2] ) verseDataList = wlc.getVerseDataList( testKey ) if verseDataList is not None: assert isinstance( verseDataList, InternalBibleEntryList ) if BibleOrgSysGlobals.verbosityLevel > 1: print( testKey ) print( "VDL", verseDataList ) print() verseText = wlc.getVerseText( testKey ) wlc.currentText = verseText if BibleOrgSysGlobals.verbosityLevel > 0: #print( "These all display left-to-right in the terminal unfortunately :-(" ) print( verseText ) verseText = wlc.removeMorphemeBreaks() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without morpheme breaks" ) print( verseText ) verseText = wlc.removeCantillationMarks() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without cantillation marks" ) print( verseText ) consonantalVerseText = wlc.removeVowelPointing() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without vowel pointing" ) print( consonantalVerseText ) print() # Check code for expanding morphological abbreviations if verseDataList is not None: for verseDataEntry in verseDataList: assert isinstance( verseDataEntry, InternalBibleEntry ) marker = verseDataEntry.getMarker() if marker in ('v~','p~'): verseDictList = wlc.getVerseDictList( verseDataEntry, testKey ) print( "verseDictList", verseDictList ) for j, verseDict in enumerate( verseDictList ): print( "verseDict", verseDict ) # for one word #word = verseDict['word'] if 'morph' in verseDict: print( " {}".format( wlc.expandMorphologyAbbreviations( verseDict['morph'] ) ) ) if 1: # Load books as we test testFolder = DEFAULT_OSIS_WLC_FILEPATH # Hebrew if BibleOrgSysGlobals.verbosityLevel > 0: print( "\nC/ Demonstrating the Hebrew WLC class (load on the go)…" ) #print( testFolder ) wlc = OSISHebrewWLCBible( testFolder ) #wlc.load() # Load and process the XML if BibleOrgSysGlobals.verbosityLevel > 0: print( wlc ) # Just print a summary print() for testReference in standardTestReferences: testKey = SimpleVerseKey( testReference[0], testReference[1], testReference[2] ) if BibleOrgSysGlobals.verbosityLevel > 1: print( testKey ) print( "VD", wlc.getVerseDataList( testKey ) ) print() verseText = wlc.getVerseText( testKey ) wlc.currentText = verseText if BibleOrgSysGlobals.verbosityLevel > 0: #print( "These all display left-to-right in the terminal unfortunately :-(" ) print( verseText ) verseText = wlc.removeMorphemeBreaks() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without morpheme breaks" ) print( verseText ) verseText = wlc.removeCantillationMarks() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without cantillation marks" ) print( verseText ) consonantalVerseText = wlc.removeVowelPointing() if BibleOrgSysGlobals.verbosityLevel > 1: print( "Without vowel pointing" ) print( consonantalVerseText ) print() if 1: # Test some of the glossing functions if BibleOrgSysGlobals.verbosityLevel > 0: print( "\nD/ Demonstrating the Hebrew WLC glossing functions…" ) wlc = OSISHebrewWLCBible( DEFAULT_OSIS_WLC_FILEPATH ) wlc.loadGlossingDict() wlc.exportGlossingDictionary() wlc.saveAnyChangedGlosses() wlc.importGlossingDictionary() wlc.importGlossingDictionary( overrideFlag=True ) if 1: # Test some of the glossing functions if BibleOrgSysGlobals.verbosityLevel > 0: print( "\nE/ Adding new references to glossing dict…" ) wlc = OSISHebrewWLCBible() wlc.loadGlossingDict() wlc.updateGenericGlossingReferences() wlc.saveAnyChangedGlosses( exportAlso = True ) if 1: # Test some of the glossing functions if BibleOrgSysGlobals.verbosityLevel > 0: print( "\nF/ Demonstrating the Hebrew WLC glossing functions…" ) if not os.path.exists( DEFAULT_ZIPPED_PICKLED_WLC_FILEPATH ): logging.critical( "HebrewWLCBible.demoF: filepath doesn't exist: {}".format( DEFAULT_ZIPPED_PICKLED_WLC_FILEPATH ) ) else: wlc = PickledHebrewWLCBible( DEFAULT_ZIPPED_PICKLED_WLC_FILEPATH ) wlc.loadGlossingDict() wlc.exportGlossingDictionary() wlc.saveAnyChangedGlosses() wlc.importGlossingDictionary() wlc.importGlossingDictionary( overrideFlag=True ) if 1: # Test some of the glossing functions if BibleOrgSysGlobals.verbosityLevel > 0: print( "\nG/ Adding new references to glossing dict…" ) if not os.path.exists( DEFAULT_ZIPPED_PICKLED_WLC_FILEPATH ): logging.critical( "HebrewWLCBible.demoG: filepath doesn't exist: {}".format( DEFAULT_ZIPPED_PICKLED_WLC_FILEPATH ) ) else: wlc = PickledHebrewWLCBible() wlc.loadGlossingDict() wlc.updateGenericGlossingReferences() wlc.saveAnyChangedGlosses( exportAlso = True )
def __init__(self, parentWindow, parentFrame, parentApp, internalBible, referenceObject): """ """ if BibleOrgSysGlobals.debugFlag: print( exp("BibleReferenceBox.__init__( {}, {}. {}, {}, {} )").format( parentWindow, parentFrame, parentApp, internalBible.getAName(), referenceObject)) self.parentWindow, self.parentFrame, self.parentApp, self.referenceObject = parentWindow, parentFrame, parentApp, referenceObject self.internalBible = handleInternalBibles(self.parentApp, internalBible, self) Frame.__init__(self, parentFrame) BibleBox.__init__(self, parentApp) # Set some dummy values required soon #self._contextViewRadioVar, self._formatViewRadioVar, self._groupRadioVar = tk.IntVar(), tk.IntVar(), tk.StringVar() #self._groupCode = BIBLE_GROUP_CODES[0] # Put into first/default BCV group #self._contextViewMode = DEFAULT #self._formatViewMode = DEFAULT self.currentVerseKey = SimpleVerseKey('UNK', '1', '1') # Unknown book #if self._contextViewMode == DEFAULT: #self._contextViewMode = 'ByVerse' #self.parentWindow.viewVersesBefore, self.parentWindow.viewVersesAfter = 2, 6 #if self._formatViewMode == DEFAULT: #self._formatViewMode = 'Formatted' # Create a title bar titleBar = Frame(self) Button(titleBar, text=_('Close'), command=self.doClose).pack(side=tk.RIGHT) ## Try to get the title width somewhere near correct (if moduleID is a long path) #adjModuleID = moduleID #self.update() # so we can get the geometry #width = parseWindowSize( self.parentWindow.winfo_geometry() )[0] - 60 # Allow for above button #if len(adjModuleID)*10 > width: # Note: this doesn't adjust if the window size is changed #print( "BRB here1", len(adjModuleID), width, repr(adjModuleID) ) #x = len(adjModuleID)*100/width # not perfect (too small) for narrow windows #adjModuleID = '…' + adjModuleID[int(x):] #print( "BRB here2", len(adjModuleID), x, repr(adjModuleID) ) #titleText = '{} ({})'.format( adjModuleID, boxType.replace( 'BibleReferenceBox', '' ) ) titleText = self.referenceObject.getShortText() self.titleLabel = tk.Label(titleBar, text=titleText) self.titleLabel.pack(side=tk.TOP, fill=tk.X) titleBar.pack(side=tk.TOP, fill=tk.X) # Create a scroll bar to fill the right-hand side of the window self.vScrollbar = Scrollbar(self) self.vScrollbar.pack(side=tk.RIGHT, fill=tk.Y) self.textBox = BText(self, height=5, yscrollcommand=self.vScrollbar.set) self.textBox.configure(wrap='word') self.textBox.pack(expand=tk.YES, fill=tk.X) # Full width self.vScrollbar.configure( command=self.textBox.yview) # link the scrollbar to the text box self.createStandardBoxKeyboardBindings() self.textBox.bind( '<Button-1>', self.setFocus ) # So disabled text box can still do select and copy functions # Set-up our standard Bible styles for USFMKey, styleDict in self.parentApp.stylesheet.getTKStyles( ).items(): self.textBox.tag_configure(USFMKey, **styleDict) # Create the style # Add our extra specialised styles self.textBox.tag_configure('contextHeader', background='pink', font='helvetica 6 bold') self.textBox.tag_configure('context', background='pink', font='helvetica 6') self.textBox.tag_configure('markersHeader', background='yellow3', font='helvetica 6 bold') self.textBox.tag_configure('markers', background='yellow3', font='helvetica 6') self.pack(expand=tk.YES, fill=tk.BOTH) # Pack the frame # Set-up our Bible system and our callables self.BibleOrganisationalSystem = BibleOrganizationalSystem( 'GENERIC-KJV-81-ENG') # temp self.getNumChapters = self.BibleOrganisationalSystem.getNumChapters self.getNumVerses = lambda b,c: MAX_PSEUDOVERSES if c=='0' or c==0 \ else self.BibleOrganisationalSystem.getNumVerses( b, c ) self.isValidBCVRef = self.BibleOrganisationalSystem.isValidBCVRef self.getFirstBookCode = self.BibleOrganisationalSystem.getFirstBookCode self.getPreviousBookCode = self.BibleOrganisationalSystem.getPreviousBookCode self.getNextBookCode = self.BibleOrganisationalSystem.getNextBookCode self.getBBBFromText = self.BibleOrganisationalSystem.getBBBFromText self.getBookName = self.BibleOrganisationalSystem.getBookName self.getBookList = self.BibleOrganisationalSystem.getBookList self.maxChaptersThisBook, self.maxVersesThisChapter = 150, 150 # temp self.verseCache = OrderedDict() self.updateShownReferences(self.referenceObject)
def demo(): """ Demonstrate how some of the above classes can be used. """ from VerseReferences import SimpleVerseKey if BibleOrgSysGlobals.verbosityLevel > 0: print(ProgNameVersion, end='\n\n') # Test the Door43CatalogResources class door43CatalogResources = Door43CatalogResources() if BibleOrgSysGlobals.verbosityLevel > 0: print(door43CatalogResources) #Door43CatalogResources.load() # takes a minute #print( Door43CatalogResources ) door43CatalogResources.fetchCatalog() if BibleOrgSysGlobals.verbosityLevel > 0: print() print(door43CatalogResources) if BibleOrgSysGlobals.debugFlag and debuggingThisModule: if BibleOrgSysGlobals.verbosityLevel > 2: print( f"\nLanguage list ({len(door43CatalogResources.languageDict)}):" ) for j, (lg, lgDict) in enumerate( door43CatalogResources.languageDict.items()): if BibleOrgSysGlobals.verbosityLevel > 2: print(' Lg', j + 1, lg, lgDict['direction'], lgDict['title']) # lgDict.keys() are lgDict['identifier'] assert 4 <= len( lgDict.keys() ) <= 6 # 'category_labels', 'direction', 'identifier', 'resources', 'title', 'versification_labels' if BibleOrgSysGlobals.verbosityLevel > 2: print(' ', len(lgDict.keys()), lgDict.keys()) for something in lgDict['resources']: assert isinstance(something, dict) if BibleOrgSysGlobals.verbosityLevel > 2: print( f" \"{something['title']}\" ({something['subject']}) ({len(something.keys())}) {something.keys()}" ) if not something['subject']: logging.critical( f"Missing subject field from {lgDict['identifier']} {something['title']}" ) elif door43CatalogResources.subjectNameList and something[ 'subject'] not in door43CatalogResources.subjectNameList: logging.critical( f"Unknown '{something['subject']}' subject field from {lgDict['identifier']} {something['title']}" ) if 'category_labels' in lgDict: if BibleOrgSysGlobals.verbosityLevel > 2: print(' category_labels', lgDict['category_labels']) if 'versification_labels' in lgDict: if BibleOrgSysGlobals.verbosityLevel > 2: print(' versification_labels', lgDict['versification_labels']) if BibleOrgSysGlobals.verbosityLevel > 2: # Neatly list all available resources print( f"\n Resource list ({len(door43CatalogResources.resourceList)}):") for j, (lg, resourceTitle, resourceEntry) in enumerate( door43CatalogResources.resourceList): print( f" {j+1:3}/ {lg:5} '{resourceTitle}' ({resourceEntry['subject']})" ) if 'formats' in resourceEntry: formats = resourceEntry['formats'] else: assert len(resourceEntry['projects']) == 1 formats = resourceEntry['projects'][0]['formats'] assert formats for formatEntry in formats: assert isinstance(formatEntry, dict) print( f" '{formatEntry['format']}' {formatEntry['url']}" ) if BibleOrgSysGlobals.verbosityLevel > 1: # List all Bibles (i.e., all USFM format) print(f"\n Bible list ({len(door43CatalogResources.BibleList)}):") for j, (lg, resourceTitle, resourceEntry) in enumerate(door43CatalogResources.BibleList): print( f" {j+1:3}/ {lg:5} '{resourceTitle}' ({resourceEntry['subject']})" ) if 'formats' in resourceEntry: formats = resourceEntry['formats'] else: assert len(resourceEntry['projects']) == 1 formats = resourceEntry['projects'][0]['formats'] assert formats for formatEntry in formats: assert isinstance(formatEntry, dict) print( f" '{formatEntry['format']}' {formatEntry['url']}" ) # List all Open Bible Stories OBSList = [] for lg, lgEntry in door43CatalogResources.languageDict.items(): for resourceEntry in lgEntry['resources']: assert isinstance(resourceEntry, dict) resourceTuple = lg, resourceEntry['title'], resourceEntry if 'Bible Stories' in resourceEntry['subject']: OBSList.append(resourceTuple) print(f"\n Bible Stories list ({len(OBSList)}):") for j, (lg, resourceTitle, resourceEntry) in enumerate(OBSList): print( f" {j+1:3}/ {lg:5} '{resourceTitle}' ({resourceEntry['subject']})" ) if 'formats' in resourceEntry: formats = resourceEntry['formats'] else: assert len(resourceEntry['projects']) == 1 formats = resourceEntry['projects'][0]['formats'] assert formats for formatEntry in formats: assert isinstance(formatEntry, dict) print( f" '{formatEntry['format']}' {formatEntry['url']}" ) testRefs = ( ('GEN', '1', '1'), ('PSA', '150', '6'), ('JER', '33', '3'), ('MAL', '4', '6'), ('MAT', '1', '1'), ('JHN', '3', '16'), ('TIT', '2', '2'), ('JDE', '1', '14'), ('REV', '22', '21'), ) if 1: # Test the Door43CatalogBible class by finding a Bible for lgCode, desiredTitle in ( ('ru', 'Russian Synodal Bible'), ('ru', 'Russian Unlocked Literal Bible'), ('ru', 'Russian Open Bible'), ('ru', 'Russion Literal Bible'), ('en', 'unfoldingWord Literal Text'), ('en', 'unfoldingWord Simplified Text'), ('fr', 'unfoldingWord Literal Text'), ('el-x-koine', 'unfoldingWord Greek New Testament'), ): if BibleOrgSysGlobals.verbosityLevel > 0: print() searchResultDict = door43CatalogResources.searchBibles( lgCode, desiredTitle) if searchResultDict: Door43CatalogBible1 = Door43CatalogBible(searchResultDict) if BibleOrgSysGlobals.verbosityLevel > 0: print(Door43CatalogBible1) Door43CatalogBible1.preload() if BibleOrgSysGlobals.verbosityLevel > 0: print(Door43CatalogBible1) for testRef in testRefs: verseKey = SimpleVerseKey(*testRef) if BibleOrgSysGlobals.verbosityLevel > 0: print(verseKey) print(" ", Door43CatalogBible1.getVerseDataList(verseKey)) if BibleOrgSysGlobals.verbosityLevel > 0: print(Door43CatalogBible1) elif BibleOrgSysGlobals.verbosityLevel > 0: print(f"{lgCode} '{desiredTitle}' was not found!")
def main(): """ This is the main program for the app Note that the standard verbosityLevel is 2: -s (silent) is 0 -q (quiet) is 1 -i (information) is 3 -v (verbose) is 4. """ if BibleOrgSysGlobals.verbosityLevel > 0: print( ProgNameVersion, end='\n\n' ) # Download the online Door43 Resource Catalog door43CatalogResources = Door43CatalogResources() if BibleOrgSysGlobals.verbosityLevel > 2: print( door43CatalogResources ) door43CatalogResources.fetchCatalog() if BibleOrgSysGlobals.verbosityLevel > 2: print() print( door43CatalogResources, end='\n\n' ) # Download and load all books from the UGNT = unfoldingWord Greek New Testament UGNTDict = door43CatalogResources.searchBibles( 'el-x-koine', 'unfoldingWord Greek New Testament' ) if UGNTDict: Door43CatalogUGNTBible = Door43CatalogBible( UGNTDict ) #if BibleOrgSysGlobals.verbosityLevel > 0: print( Door43CatalogUGNTBible ) Door43CatalogUGNTBible.preload() #if BibleOrgSysGlobals.verbosityLevel > 0: print( Door43CatalogUGNTBible ) Door43CatalogUGNTBible.load() if BibleOrgSysGlobals.verbosityLevel > 0: print( Door43CatalogUGNTBible, end='\n\n' ) # Download the ULT = unfoldingWord Literal Text ULTDict = door43CatalogResources.searchBibles( 'en', 'unfoldingWord Literal Text' ) if ULTDict: Door43CatalogULTBible = Door43CatalogBible( ULTDict ) #if BibleOrgSysGlobals.verbosityLevel > 0: print( Door43CatalogULTBible ) Door43CatalogULTBible.preload() if BibleOrgSysGlobals.verbosityLevel > 0: print( Door43CatalogULTBible, end='\n\n' ) # Go through the UGNT verse by verse # and do some comparisions with the matching ULT verses # NOTE: This code assumes matching versification systems count1 = count2 = 0 for BBB, UGNTBook in Door43CatalogUGNTBible.books.items(): for C in range( 1, Door43CatalogUGNTBible.getNumChapters( BBB )+1 ): for V in range( 1, Door43CatalogUGNTBible.getNumVerses( BBB, C )+1 ): ref = SimpleVerseKey( BBB, C, V ) text1 = Door43CatalogUGNTBible.getVerseText( ref, fullTextFlag=False ) if not text1: logging.warning( f"Blank text at {ref.getShortText()} in UGNT" ) try: # NOTE: The following line will automatically load the ULT book into memory as required text2 = Door43CatalogULTBible.getVerseText( ref, fullTextFlag=False ) if not text2: logging.warning( f"Blank text at {ref.getShortText()} in ULT" ) except KeyError: logging.error( f"Can't find {ref.getShortText()} in ULT" ) text2 = '' # Now that we have text1 and text2 for the verse specified in ref, # do our analysis/comparison now J1 = 'Ἰησοῦς' in text1 or 'Ἰησοῦ' in text1 or 'Ἰησοῦν' in text1 J2 = 'Jesus' in text2 if J1 and not J2: if BibleOrgSysGlobals.verbosityLevel > 1: print( f"Found 'Jesus' in Grk {ref.getShortText()}: {text1}" ) print( f" {text2}" ) count1 += 1 if J2 and not J1: if BibleOrgSysGlobals.verbosityLevel > 1: print( f"Found 'Jesus' in ULT {ref.getShortText()}: {text2}" ) print( f" {text1}" ) count2 += 1 if BibleOrgSysGlobals.verbosityLevel > 0: print( f"\nFound {count1} unmatched occurrences in UGNT, {count2} in ULT." )