forked from TorahBibleCodes/TorahBibleCodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_7_DictionaryOfVersesCreate.py
More file actions
152 lines (105 loc) · 5.46 KB
/
Copy pathmod_7_DictionaryOfVersesCreate.py
File metadata and controls
152 lines (105 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
## IMPORT MODULES
## FUNCTION () #7 - DICTIONARY OF VERSES CREATE ##
def fn_DictionaryOfVersesCreate(ZippedTupleNoSpaces, ZippedTupleWithSpaces):
"""
## MODULE.FUNCTION() #7 - CREATE 2 DICTIONARY OF VERSES OF TEXTS CHOSEN TO BE SEARCHED; RETURNS DictOfVersesNoSpaces, DictOfVersesWithSpaces
"""
## TEST PRINT OUTPUT
print("\n") ## PRINT SPACE
print("WITHIN FUNCTION: BEGIN FUNCTION #7 - DICTIONARY OF VERSES CREATE")
## DECLARE VARIABLES
DictOfVersesNoSpaces = {} ## EMPTY DICTIONARY TO HOLD KEYS + VERSES
DictOfVersesWithSpaces = {} ## EMPTY DICTIONARY TO HOLD KEYS + VERSES
## BELOW FOR ZIPPED TUPLE WITH NO SPACES
## EACH IS ZIPPED TUPLE: INTEGER, DICTIONARY
for each in ZippedTupleNoSpaces:
## TEST PRINT OUTPUT - each[0] = integer; each[1] = dictionary object
## print(each[0], each[1]['title'])
## print(len(each[1]['text'])) ## len(d['text']) = NUMBER OF CHAPTERS IN SELECTED TEXT
## print(type(each[1]['text'])) # type(d['text']) = LIST OF CHAPTERS (LIST OF LISTS) IN SELECTED TEXT
NumberOfBook = each[0]
NumberOfChapters = len(each[1]['text'])
## TEST PRINT OUTPUT
## print(NumberOfBook, NumberOfChapters)
ChapterCounter = 1
for Chapter in each[1]['text']:
## TEST PRINT OUTPUT
## print("\n") ## PRINT SPACE
## print("NumberOfBook = ", NumberOfBook)
## print("NumberOfChapters = ", NumberOfChapters)
## print("NumberOfChapter = ", ChapterCounter)
## print("Chapter = ", Chapter)
VerseCounter = 1
for Verse in Chapter:
## TEST PRINT OUTPUT
## print("\n") ## PRINT SPACE
## print("NumberOfChapter = ", ChapterCounter)
## print("NumberOfVerse = ", VerseCounter)
KeyTuple = (NumberOfBook, ChapterCounter, VerseCounter)
## TEST PRINT OUTPUT
## print("KeyTuple = ", KeyTuple)
## print("Verse = ", Verse)
DictOfVersesNoSpaces[KeyTuple] = Verse
VerseCounter += 1
ChapterCounter += 1
## BELOW FOR ZIPPED TUPLE WITH SPACES
## EACH IS ZIPPED TUPLE: INTEGER, DICTIONARY
for each in ZippedTupleWithSpaces:
## TEST PRINT OUTPUT - each[0] = integer; each[1] = dictionary object
## print(each[0], each[1]['title'])
## print(len(each[1]['text'])) ## len(d['text']) = NUMBER OF CHAPTERS IN SELECTED TEXT
## print(type(each[1]['text'])) # type(d['text']) = LIST OF CHAPTERS (LIST OF LISTS) IN SELECTED TEXT
NumberOfBook = each[0]
NumberOfChapters = len(each[1]['text'])
## TEST PRINT OUTPUT
## print(NumberOfBook, NumberOfChapters)
ChapterCounter = 1
for Chapter in each[1]['text']:
## TEST PRINT OUTPUT
## print("\n") ## PRINT SPACE
## print("NumberOfBook = ", NumberOfBook)
## print("NumberOfChapters = ", NumberOfChapters)
## print("NumberOfChapter = ", ChapterCounter)
## print("Chapter = ", Chapter)
VerseCounter = 1
for Verse in Chapter:
## TEST PRINT OUTPUT
## print("\n") ## PRINT SPACE
## print("NumberOfChapter = ", ChapterCounter)
## print("NumberOfVerse = ", VerseCounter)
KeyTuple = (NumberOfBook, ChapterCounter, VerseCounter)
## TEST PRINT OUTPUT
## print("KeyTuple = ", KeyTuple)
## print("Verse = ", Verse)
## TEST DEVELOPMENT - BEGIN
## BEGIN DEAL WITH DOUBLE WHITE SPACES
## CONVERT STRING WITH SPACES TO LIST
## DECLARE VARIABLE TO DEAL WITH THE "WORDS" WITH EMPTY STRINGS
ListOfWords = []
## SPLIT TEXT INTO INDIVIDUAL WORDS: CREATES LIST OF WORDS
ListOfWordsInVerse = list(Verse.split(" "))
## BEGIN FOR LOOP
for each in ListOfWordsInVerse:
## BEGIN IF / ELSE... DEAL WITH THE "WORDS" WITH EMPTY STRINGS TO FILTER OUR DOUBLE-SPACES
if each =='':
pass
else:
ListOfWords.append(each)
## END IF / ELSE
## END FOR LOOP
## JOIN LIST OF WORDS
Verse = " ".join(ListOfWords)
## END DEAL WITH DOUBLE WHITE SPACES
## TEST DEVELOPMENT - END
## ASSIGN EACH VERSE TO EACH 3-INTEGER TUPLE-KEY --> DS[1,1,1] or DS[(1,1,1)]
DictOfVersesWithSpaces[KeyTuple] = Verse
## INCREMENT VERSE COUNTER
VerseCounter += 1
## INCREMENT CHAPTER COUNTER
ChapterCounter += 1
## TEST PRINT OUTPUT
print("\n") ## PRINT SPACE
print("WITHIN FUNCTION: END FUNCTION #7 - DICTIONARY OF VERSES CREATE")
## RETURN VARIABLES TO PROGRAM
return(DictOfVersesNoSpaces, DictOfVersesWithSpaces)
## END FUNCTION() #7 - DICTIONARY OF VERSES CREATE