unit fonet; interface const souhl:set of char=[')','B','G','D','H','W','Z','X','+','Y','K','L', 'M','N','S','(','P','C','Q','R','&','$','T']; samohl:set of char=['A','F','E','"','I','O','U']; { upcas: budou se nektere pismena zobrazovat jako velka? (kvuli cteni skrze hlasovy vystup kuk) upc_a: podvolba pro ajin a alef } config_upcas:boolean =true; config_upc_a:boolean =true; {vypisovat pri hledani zacatku kapitol tecky ?} config_seek_w:boolean= true; type w=record book:array[1..2] of char; num:array[1..4] of byte; wor,lem,morf:string; kere,note,langu,st:char; end; analys1=record sou,sam:char; dag,she,acc:boolean; delk:byte; end; analys2=record sou1,sam,sou2:char; dag1,dag2,she,acc,uzav,furt,upc,upc_n:boolean; delk:byte; end; Fchr=file of char; Tloader=object buffer:string; bf:array [1..1024] of char; bfpos,bfres:word; ef:boolean; chap_pos:longint; nm: array [1..3] of byte; procedure init; function readbf(var f:file):char; function eof:boolean; function readstr(var f:file):string; function loadlin(var f:file):string; procedure findchap(ch:byte;var f:file); procedure seekchap(var f:file); end; var bks:array [1..39] of record b:array[1..2] of char; e:array[1..4] of char; n:string; end; dr:string; {*}procedure bksinit; {*}procedure divi(s:string; var d:w); function transf(s:string):string; function deco(var ww:w):string; function upcas(ch:char):char; function trans_hs(s:string):string; function trans_cz(s:string):string; {*}function trans_sh(s:string):string; {*}function trans_sm(s:string):string; function syl (s:string; i:byte): byte; procedure anl1 (s:string;f, t:byte; var an:analys1); function podklad(s:string;i:byte;var an:analys1):byte; function anl(s:string; f:byte;var an:analys2):byte; {*}procedure clean_anl(an:analys2); function rekni_s(ch:char;dages,furt:boolean;var upc:boolean):string; function rekni_sm(ch:char;delk:byte):string; function rekni(an,an_l:analys2):string; {*}function fonetic(s:string):string; implementation procedure bksinit; var f:text; s:string; i:byte; begin assign(f,dr+'morf94.dir'); reset(f); for i:=1 to 39 do with bks[i] do begin readln(f,s); b[1]:=s[1]; b[2]:=s[2]; e[1]:=s[4]; e[2]:=s[5]; e[3]:=s[6]; e[4]:=s[7]; n:=copy(s,9,length(s)-8); end; close(f); end; {==============================================================} {==============================================================} {==============================================================} procedure divi(s:string; var d:w); var i,j,ll:byte; cd:integer; begin with d do begin kere:=' '; note:=' '; book[1]:=upcase(s[1]); book[2]:=upcase(s[2]); i:=3; j:=pos(':',s); val(copy(s,i,j-i),num[1],cd); i:=j+1; j:=pos(',',s); val(copy(s,i,j-i),num[2],cd); i:=j+1; j:=pos('.',s); val(copy(s,i,j-i),num[3],cd); i:=j+1;j:=i+1; val(copy(s,i,j-i),num[4],cd); {============== note ======================} if s[j]=']' then begin note:=s[j+1]; j:=j+2; end; i:=j+1; j:=pos(' ',copy(s,i,length(s)-i+1))+i-1; wor:=copy(s,i,j-i); {==================== Kere - Qetib =======} if pos('*',wor)>0 then begin ll:=pos('*',wor); if wor[ll+1]='*' then begin kere:='Q'; wor:=copy(wor,1,ll-1)+copy(wor,3,length(wor)-2); end else begin kere:='K'; wor:=copy(wor,1,ll-1)+copy(wor,2,length(wor)-1); end; end; i:=j+1; if pos('%',s)=0 then j:=pos('@',copy(s,i,length(s)-i+1))+i-1 else j:=pos('%',copy(s,i,length(s)-i+1))+i-1; lem:=copy(s,i,j-i); morf:=copy(s,j,length(s)-i+1); end; end; {==============================================================} {==============================================================} {==============================================================} function transf(s:string):string; var i:byte; ou:string; begin ou:=''; for i:= 1 to length(s) do case s[i] of '(':ou:=ou+'`'; ')':ou:=ou+''''; 'X':ou:=ou+'Ch'; '+':ou:=ou+'Th'; 'Y':ou:=ou+'J'; '$':ou:=ou+'Sh'; '&':ou:=ou+'Ss'; '#':ou:=ou+'Sz'; 'A':ou:=ou+'a'; 'F':ou:=ou+' '; 'E':ou:=ou+'e'; '"':ou:=ou+'‚'; 'I':ou:=ou+'i'; 'U':ou:=ou+'u'; 'O':if ilength(s)) or (s[j] in souhl)); j:=j-1; syl:=j; end; { analyzuje jeden segment (=souhlaska & spol.) } { f: zacatek segmentu (offset v s:string) } { t: konec segmentu (offset v s:string) } { an: record > vysledna analyza } procedure anl1 (s:string;f, t:byte; var an:analys1); var i:byte; begin with an do begin sou:=' ';sam:=' ';dag:=false;acc:=false;she:=false;delk:=0; i:=f; while (i<=t) do begin case s[i] of ':':she:=true; '.':dag:=true; '^':acc:=true; else if s[i] in souhl then sou:=s[i] else if s[i] in samohl then sam:=s[i]; end; i:=i+1; end; end; end; {zjisti, jestli k segmentu patri dalsi jakozto podklad} function podklad(s:string;i:byte;var an:analys1):byte; var j,jj,k,last:byte; an1,an2:analys1; begin with an do begin j:=syl(s,i); {najde konec prvniho segmentu } anl1(s,i,j,an); {a zanalyzuje} last:=j; if not (she or (j=length(s))) then {je to segment se ¨evou, nebo posledn¡ s. ?} begin {neni, zkus, jestli dalsi souhl ska nen¡ podkladem} k:=j+1; j:=syl(s,k); {najde konec dalsiho segmentu } anl1(s,k,j,an1); {a zanalyzuje} if (an1.sam=' ') and not (an1.she) then case an1.sou of {vyzhousej jednotlive podklady} ')':if sam<>' ' then begin delk:=2; last:=j; acc:=acc or an1.acc end; 'Y':if sam in ['E','"','I'] then begin delk:=2; last:=j; acc:=acc or an1.acc end else if (sam='F') and (an1.sou='Y') and (j vysledna analyza } { vysledek : konec slabiky (offset) } function anl(s:string; f:byte;var an:analys2):byte; var i,last:byte; an1,an2:analys1; begin with an do begin sou1:=' '; sou2:=' '; sam:=' '; dag1:=false; dag2:=false; she:=false; acc:=false; delk:=0; uzav:=false; furt:=false; upc:=false; upc_n:=false; i:=podklad(s,f,an1); {vezme a zanalyzuje prvni segment} sou1:=an1.sou; dag1:=an1.dag; acc:=an1.acc; { vezme prizvuk, je-li } she:=an1.she; sam:=an1.sam; last:=i; if she or (i=length(s)) then {je to segment se ¨evou, nebo posledn¡ s. ?} begin uzav:=false; {ano, rozhodnˆ se tedy nejedn  o uzav©enou sl.} delk:=3; {je to pokud mo‘no dloh  samohl ska} if she and (sam=' ') then upc_n:=true; if (i=length(s)) and (sou1='X') then furt:=true; if (i=length(s)) and (sou1='H') and dag1 then furt:=true; {patah furtivum} end else { ne, tedy mus¡me prozkoumat dal¨¡ segment } begin i:=podklad(s,i+1,an2); if not(an2.sam in samohl) then {stoji u dalsi souhl. samohl? } begin {ne, tak je to uzavrena slabika} uzav:=true; sou2:=an2.sou; dag2:=an2.dag; acc:=acc or an2.acc; if not acc then delk:=1; last:=i; end; if an2.dag and (sam in samohl) then {je v dalsi souhl. dage¨ forte ?} begin {ano, je to uzavrena slabika} uzav:=true; sou2:=an2.sou; dag2:=an2.dag; upc_n:=true; {Pismeno bude UPCASE kvuli hlasovemu vystupu } if not acc then delk:=1; end; end; anl:=last; end; end; procedure clean_anl(an:analys2); begin with an do begin sou1:=' '; sou2:=' '; sam:=' '; dag1:=false; dag2:=false; she:=false; acc:=false; delk:=0; uzav:=false; furt:=false; upc:=false; upc_n:=false; end; end; function rekni_s(ch:char;dages,furt:boolean;var upc:boolean):string; var o,od:string; d:boolean; begin d:=false; case ch of '(':begin o:=''; if config_upc_a and not(furt) then upc:=true; end; ')':begin o:=''; if config_upc_a then upc:=true; end; 'X':o:='ch'; '+':o:='t'; 'Y':o:='j'; '$':o:='¨'; '&':o:='s'; '#':o:='¨'; 'B':begin o:='v'; od:='b'; d:=true; end; 'G':o:='g'; 'D':o:='d'; 'H':o:='h'; 'W':begin o:='v'; od:='£'; d:=true; end; 'Z':o:='z'; 'K':begin o:='ch'; od:='k'; d:=true; end; 'L':o:='l'; 'M':o:='m'; 'N':o:='n'; 'S':o:='s'; 'P':begin o:='f'; od:='p'; d:=true; end; 'C':o:='c'; 'Q':o:='k'; 'R':o:='r'; 'T':o:='t'; end; if dages and d then rekni_s:=od else rekni_s:=o; end; function rekni_sm(ch:char;delk:byte):string; var d,k,p:string; begin p:='';d:='';k:=''; case ch of 'A':begin p:='a'; d:='a'; k:='a'; end; 'F':begin p:=' '; d:=' '; k:='o'; end; 'E':begin p:='‚'; d:='e'; k:='e'; end; '"':begin p:='‚'; d:='‚'; k:='‚'; end; 'I':begin p:='¡'; d:='¡'; k:='i'; end; 'O':begin p:='¢'; d:='¢'; k:='¢'; end; 'U':begin p:='£'; d:='£'; k:='u'; end; end; case delk of 0,3:rekni_sm:=d; {vetsinou dlouhe } 1:rekni_sm:=k; {vzdy kratke} 2:rekni_sm:=p; {podklad (vzdy dlouhe) } end; end; function rekni(an,an_l:analys2):string; var s:string; b:boolean; begin with an do begin s:=''; if furt then s:=s+rekni_sm(sam,delk); s:=s+rekni_s(sou1,dag1,furt,upc); if not(furt) then s:=s+rekni_sm(sam,delk); if uzav then s:=s+rekni_s(sou2,dag2,furt,b); end; if an.upc or an_l.upc_n then s[1]:=upcas(s[1]); rekni:=s; end; function fonetic(s:string):string; var i:byte; an,an1:analys2; t:string; begin if trans_hs(s)='YHWH' then fonetic:='Ad¢naj' else begin i:=0; clean_anl(an1); t:=''; repeat i:=i+1; i:=anl(s,i,an); t:=t+rekni(an,an1); an1:=an; until (i>=length(s)) ; fonetic:=t; end; end; {**************************************************} procedure Tloader.init; begin buffer:=''; bfpos:=0; bfres:=1; ef:=false; end; function Tloader.readbf(var f:file):char; begin if bfpos=0 then begin blockread(f,bf,1024,bfres); if bfres>0 then bfpos:=1 else ef:=true; end; if (bfpos<=1024) and (bfpos>0) then begin readbf:=bf[bfpos]; bfpos:=bfpos+1; end; if (bfpos>1024) then begin blockread(f,bf,1024,bfres); if bfres>0 then bfpos:=1 else ef:=true; end; end; function Tloader.eof:boolean; begin eof:=ef; end; function Tloader.readstr(var f:file):string; var i:char; s:string; begin i:=#0; s:=''; while not(eof or (i=#10)) do begin i:=readbf(f); if not(i in [#10,#13]) then s:=s+i; end; readstr:=s; end; procedure Tloader.findchap(ch:byte;var f:file); {! nutno pouzit hned po otevreni souboru !!!!} var s,t:string; begin str(ch,t); t:=t+':1'; while not(eof or ((s[1]='>') and (copy(s,4,length(s)-3)=t))) do begin s:=readstr(f); if (s[1]='>') and (copy(s,5,length(s)-4)=':1') then write('.'); if (s[1]='>') and (copy(s,6,length(s)-5)=':1') then write('.'); end; chap_pos:=FilePos(f); end; procedure Tloader.seekchap(var f:file); begin seek(f,chap_pos); buffer:=''; end; function Tloader.loadlin(var f:file):string; var s,t:string; ww:w; i,j,k:byte; a:char; begin repeat if buffer<>'' then begin s:=buffer; buffer:=''; end else begin s:=readstr(f); if s[1]='>' then s:=readstr(f); end; divi(s,ww); nm[1]:=ww.num[1];nm[2]:=ww.num[2];nm[3]:=ww.num[3]; t:=''; i:=ww.num[3];j:=ww.num[2];k:=ww.num[1]; while not(eof or (i<>ww.num[3]) or (j<>ww.num[2]) or (k<>ww.num[1]) or (t[length(t)]='-')) do begin t:=t+ww.wor; s:=readstr(f); if s[1]='>' then s:=readstr(f); nm[1]:=ww.num[1];nm[2]:=ww.num[2];nm[3]:=ww.num[3]; divi(s,ww); end; buffer:=s; until (t<>''); loadlin:=t; end; {**************************************************} {**************************************************} {**************************************************} {**************************************************} begin end.