diff --git a/build-pts.js b/build.js similarity index 50% rename from build-pts.js rename to build.js index af858d2..6912860 100644 --- a/build-pts.js +++ b/build.js @@ -1,9 +1,9 @@ const fs=require("fs"); const folder="../pts-dhammakaya/data/"; -const {createbuilder}=require("dengine"); +const {createbuilder}=require("pengine"); const booknames=[ - 'mv','cv','vb1' ,'vb2','pvr' + '','mv','cv','vb1' ,'vb2','pvr' //1~5 ,'dn1','dn2','dn3'//6~8 ,'mn1','mn2','mn3'//9~11 ,'sn1','sn2','sn3','sn4','sn5'//12~16 @@ -16,21 +16,39 @@ const booknames=[ ,'ds','vb','dt','pp','kv' //43,44,45,46,47 ,'ya1','ya2' // 48,49 ,'pt1','pt2','pt3','pt4','pt5','pt6'//50,51,52,53,54,55 - ] -const LASTBOOK='pt1';//pt is not complete in dhammakaya database + +const booknames_a={ + 1:'vin-a',2:'vin-a',3:'vin-a',4:'vin-a',5:'vin-a',6:'vin-a',7:'vin-a', + 8:'dn-a',9:'dn-a',10:'dn-a', + 12:'mn-a1',13:'mn-a2',14:'mn-a3',15:'mn-a4',16:'mn-a5', + 17:'sn-a1',18:'sn-a2',19:'sn-a3', + 20:'an-a1',21:'an-a2',22:'an-a3',23:'an-a4',24:'an-a5', + 25:'kp-a',26:'dhp-a1',27:'dhp-a2',28:'dhp-a3',29:'dhp-a4', + 30:'ud-a',31:'iti-a1' ,32:'iti-a2', 33:'snp-a',34:'snp-a', + 35:'vv-a',36:'pv-a',37:'thag-a1',38:'thag-a2',39:'thag-a3', + 40:'thig-a', 41:'mnd-a',42:'mnd-a',43:'cnd-a',44:'ps-a',45:'ps-a',46:'ps-a', + 47:'ap-a',48:'bv-a',49:'cp-a',50:'ds-a',51:'vb-a', + 57:'mil',58:'vism' +} +const LASTBOOK='pt2';//pt is not complete in dhammakaya database const rawtext=[]; -const dofile=(fn,builder)=>{ +const dofile=(fn,builder,att)=>{ console.log("processing",fn); let content=fs.readFileSync(fn,"utf8").split(/\r?\n/); - let prevbk=0,page=0,line=0; + let prevbk='',bk='',page=0,line=0; const MAXLINE=content.length; for (var i=0;i52)bkseq=52; - const bk=booknames[bkseq],page=parseInt(arr[1]); + if (att) { + bk=booknames_a[arr[0]]; + } else { + let bkseq=parseInt(arr[0]); + if (bkseq>52)bkseq=52; + bk=booknames[bkseq] + } + page=parseInt(arr[1]); if (arr.length<3) continue; const lines=arr[2].split("\\n"); @@ -48,20 +66,22 @@ const dofile=(fn,builder)=>{ builder.addpage(page); prevbk=bk; } - builder.addbook(LASTBOOK); + builder.addbook(prevbk); } const outputrawtext=true; -const build=(tsv,name)=>{ +const build=(name)=>{ const out=[],footnote=[]; const builder=createbuilder({name}); - dofile(folder+tsv,builder); + + dofile(folder+'palipg1.tsv',builder,); + dofile(folder+'palipg2.tsv',builder,true); builder.done(); if (outputrawtext) { - fs.writeFileSync("pts-raw.txt",rawtext.join("\n"),"utf8"); + fs.writeFileSync(name+"-raw.txt",rawtext.join("\n"),"utf8"); } } -build('palipg1.tsv','pts'); \ No newline at end of file +build('pts'); \ No newline at end of file diff --git a/gen-pts.js b/gen-pts.js deleted file mode 100644 index e69de29..0000000