#!/usr/bin/perl -w # This program converts a eng-rom database from stdin # to TEI dictionary format on stdout. # No sorting is done. # # V1.0 GPLŽed 2002 by H.Eyermann # V1.1 Michael Bunk: simplified script, converted to TEI P4 sub xmlescape { my $w = shift; $w =~ s/&/&/g; $w =~ s/\'/"/g; $w =~ s/\"/'/g; $w =~ s//>/g; $w; } # print the header system 'cat eng-rom.tei.header'; # read the database from stdin $orth = ""; while(<>) { # if the line doesn't start with whitespace if(/^(\S+)/) { # if we had read an entry before, output it if($orth) { print<
$orth $pron
$tran EOF } # recognize next headword if(/\:(.+)\:/) { $orth = xmlescape($1); $pron = ""; $tran = ""; } else { chomp; warn "Line $.: Didn't find headword in '$_'\n"; } next; } # why this, while there is no pronunciation information # in the dictionary source? if(/^\[(.*)\]$/) { $pron = " $1\n"; next; } chomp; next if $_ eq ""; # parse entry contents foreach $tr (split /,/) { $tr =~ s/^\s*//g;# delete leading $tr =~ s/\s*$//g;# and trailing spaces $tr = xmlescape($tr); $tran .= " $tr\n"; } } # while # print the footer print< EOF