Skip to content

Commit

Permalink
#73 Construction of link target for manu
Browse files Browse the repository at this point in the history
  • Loading branch information
funderburkjim committed Sep 7, 2024
1 parent 1f6c650 commit e7a23c2
Show file tree
Hide file tree
Showing 6 changed files with 4,108 additions and 0 deletions.
311 changes: 311 additions & 0 deletions pwgissues/issue73/Manu.Deslongchamps.index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
page Adhyaya From (verse) To (verse)
1 --- --- ---
2 --- --- ---
3 1 1 5
4 1 6 14
5 1 15 23
6 1 24 32
7 1 33 41
8 1 42 50
9 1 51 59
10 1 60 68
11 1 69 77
12 1 78 86
13 1 87 95
14 1 96 104
15 1 105 113
16 1 114 119
17 2 1 7
18 2 8 16
19 2 17 25
20 2 26 34
21 2 35 43
22 2 44 52
23 2 53 61
24 2 62 70
25 2 71 79
26 2 80 88
27 2 89 97
28 2 98 106
29 2 107 115
30 2 116 124
31 2 125 133
32 2 134 142
33 2 143 151
34 2 152 160
35 2 161 169
36 2 170 178
37 2 179 187
38 2 188 196
39 2 197 205
40 2 206 214
41 2 215 223
42 2 224 232
43 2 233 241
44 2 242 249
45 3 1 7
46 3 8 16
47 3 17 25
48 3 26 34
49 3 35 43
50 3 44 52
51 3 53 61
52 3 62 70
53 3 71 79
54 3 80 88
55 3 89 97
56 3 98 106
57 3 107 115
58 3 116 124
59 3 125 133
60 3 134 142
61 3 143 151
62 3 152 160
63 3 161 169
64 3 170 178
65 3 179 187
66 3 188 196
67 3 197 205
68 3 206 214
69 3 215 223
70 3 224 232
71 3 233 241
72 3 242 250
73 3 251 259
74 3 260 268
75 3 269 276
76 3 277 284
77 3 285 286
78 4 1 6
79 4 7 15
80 4 16 24
81 4 25 33
82 4 34 42
83 4 43 51
84 4 52 60
85 4 61 69
86 4 70 78
87 4 79 87
88 4 88 96
89 4 97 105
90 4 106 114
91 4 115 123
92 4 124 132
93 4 133 141
94 4 142 150
95 4 151 159
96 4 160 168
97 4 169 177
98 4 178 186
99 4 187 195
100 4 196 204
101 4 205 213
102 4 214 222
103 4 223 231
104 4 232 240
105 4 241 249
106 4 250 258
107 4 259 260
108 5 1 6
109 5 7 15
110 5 16 24
111 5 25 33
112 5 34 42
113 5 43 51
114 5 52 60
115 5 61 69
116 5 70 78
117 5 79 87
118 5 88 96
119 5 97 105
120 5 106 114
121 5 115 123
122 5 124 132
123 5 133 141
124 5 142 150
125 5 151 159
126 5 160 168
127 5 169 169
128 6 1 6
129 6 7 15
130 6 16 24
131 6 25 33
132 6 34 42
133 6 43 51
134 6 52 60
135 6 61 69
136 6 70 78
137 6 79 87
138 6 88 96
139 6 97 97
140 7 1 7
141 7 8 16
142 7 17 25
143 7 26 34
144 7 35 43
145 7 44 52
146 7 53 61
147 7 62 70
148 7 71 79
149 7 80 88
150 7 89 97
151 7 98 106
152 7 107 115
153 7 116 124
154 7 125 133
155 7 134 142
156 7 143 151
157 7 152 160
158 7 161 169
159 7 170 178
160 7 179 187
161 7 188 196
162 7 197 205
163 7 206 214
164 7 215 223
165 7 224 226
166 8 1 7
167 8 8 16
168 8 17 25
169 8 26 34
170 8 35 43
171 8 44 52
172 8 53 61
173 8 62 70
174 8 71 79
175 8 80 88
176 8 89 97
177 8 98 106
178 8 107 115
179 8 116 124
180 8 125 133
181 8 134 142
182 8 143 151
183 8 152 160
184 8 161 169
185 8 170 178
186 8 179 187
187 8 188 196
188 8 197 205
189 8 206 214
190 8 215 223
191 8 224 232
192 8 233 241
193 8 242 250
194 8 251 259
195 8 260 268
196 8 269 277
197 8 278 286
198 8 287 295
199 8 296 304
200 8 305 313
201 8 314 322
202 8 323 331
203 8 332 340
204 8 341 349
205 8 350 358
206 8 359 367
207 8 368 376
208 8 377 385
209 8 386 394
210 8 395 403
211 8 404 412
212 8 413 420
213 9 1 7
214 9 8 16
215 9 17 25
216 9 26 34
217 9 35 43
218 9 44 52
219 9 53 61
220 9 62 70
221 9 71 79
222 9 80 88
223 9 89 97
224 9 98 106
225 9 107 115
226 9 116 124
227 9 125 133
228 9 134 142
229 9 143 151
230 9 152 160
231 9 161 169
232 9 170 178
233 9 179 187
234 9 188 196
235 9 197 205
236 9 206 214
237 9 215 223
238 9 224 232
239 9 233 241
240 9 242 250
241 9 251 259
242 9 260 268
243 9 269 277
244 9 278 286
245 9 287 295
246 9 296 304
247 9 305 313
248 9 314 322
249 9 323 331
250 9 332 336
251 10 1 7
252 10 8 16
253 10 17 25
254 10 26 34
255 10 35 43
256 10 44 52
257 10 53 61
258 10 62 70
259 10 71 79
260 10 80 88
261 10 89 97
262 10 98 106
263 10 107 115
264 10 116 124
265 10 125 131
266 11 1 7
267 11 8 16
268 11 17 25
269 11 26 34
270 11 35 43
271 11 44 52
272 11 53 61
273 11 62 70
274 11 71 79
275 11 80 88
276 11 89 97
277 11 98 106
278 11 107 115
279 11 116 124
280 11 125 133
281 11 134 142
282 11 143 151
283 11 152 160
284 11 161 169
285 11 170 178
286 11 179 187
287 11 188 196
288 11 197 205
289 11 206 214
290 11 215 223
291 11 224 232
292 11 233 241
293 11 242 250
294 11 251 259
295 11 260 265
296 12 1 7
297 12 8 16
298 12 17 25
299 12 26 34
300 12 35 43
301 12 44 52
302 12 53 61
303 12 62 70
304 12 71 79
305 12 80 88
306 12 89 97
307 12 98 106
308 12 107 115
309 12 116 124
310 12 125 126
79 changes: 79 additions & 0 deletions pwgissues/issue73/make_manudata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# coding=utf-8
""" make_manudata.py
"""
from __future__ import print_function
import sys, re,codecs

def read_lines(filein):
with codecs.open(filein,encoding='utf-8',mode='r') as f:
lines = [x.rstrip('\r\n') for x in f]
print(len(lines),"read from",filein)
return lines

def write_lines(fileout,outarr,printFlag=False):
with codecs.open(fileout,"w","utf-8") as f:
for out in outarr:
f.write(out+'\n')
if printFlag:
print(len(outarr),"lines written to",fileout)

class Rec:
def __init__(self,line):
self.status = False # True for 'normal' line
self.line = line
parts = line.split('\t') # tab-delimited, 4 fields
assert len(parts) == 4
if parts[0] in ['page','1','2']:
# not a normal page. skip
print('skip line with page=%s' % parts[0])
return

self.ipage = int(parts[0])
self.adhyaya = int(parts[1]) # 1-12, section
self.shlokafirst = int(parts[2]) # first shloka that begins on this page
self.shlokalast = int(parts[3]) # last shloka that begins on this page
# computed
# epage (pdf page number) a linear translation from ipage
self.epage = self.ipage + 21
self.status = True
self.shlokamap = []

def init_recs(lines):
recs = []
for line in lines:
rec = Rec(line)
if rec.status == True:
recs.append(rec)
print(len(recs),"records from AB index file")
return recs

def update_recs(recs):
# construct rec.shlokamap
# 40 2,79-83 -> {'2,79':'1040`, '2,80':'1040', ..., '2,83':'1040'}

for irec,rec in enumerate(recs):
epage3 = '%03d' % rec.epage
page = epage3
for s in range(rec.shlokafirst,rec.shlokalast + 1):
a = "'%s,%s':'%s'" %(rec.adhyaya,s,page)
rec.shlokamap.append(a)

def write_recs(fileout,recs):
# make a javascript file
outarr = []
outarr.append('var manudata={') # begin the JS object literal
for rec in recs:
for smap in rec.shlokamap:
outarr.append('%s,' % smap)
outarr.append('}') # end the JS object literal
write_lines(fileout,outarr,printFlag=True)

if __name__=="__main__":
filein = sys.argv[1] # Manu.Deslongchamps.index.txt
fileout = sys.argv[2] # javascript
lines = read_lines(filein)
recs = init_recs(lines)
print(len(recs),"records from",filein)
update_recs(recs)
write_recs(fileout,recs)

Loading

0 comments on commit e7a23c2

Please sign in to comment.