#!/usr/bin/perl
#
# langen2kvtml - Converts langenscheidt *.voc to kvoctrain's *.kvtml
#            Does the following:
#		analyse general header
#		remove langenscheidt specific information
#		continously rewrite the first of three lines giving:
#		+ foreign word
#		+ translation
#		+ chapter
#		while guessing word type information for entries in:
#		+ German
#		+ English
#		+ French
#		+ Spanish
#		rewrite lesson names 
#		append tables for conjugation and articles in:
#		+ German
#		+ English
#		+ French
#		+ Spanish
#		+ Italian
#		+ Czechian
#
# Options:
#	voc 			- *.voc file
#
# Version 0.1 22/08/01 - Andreas Neuper
#	initial release
#
# Version 0.2 20/09/01 - Andreas Neuper
#	extensions:
#		language recognition added (derived from input filename)
#		added (guessed) type information for English and Spanish
#		modifying kde-config file to add language
#	corrections:
#		resolved difficulties (CR left) with Lesson information
#
# Version 0.3 22/09/01 - Andreas Neuper
#	extensions:
#		added (guessed) type information for French
#		Article and conjugation tables added for:
#		    French, English, Italian, and Czechian
#		added Verb recognition by local ending (95or conjuga2K14GenOptPageFOperl
#u070100029a0a000081ed0000000000000000000000 defiOperl
#	+ chwith Lesson informae
#	cor#		+ s29a0a000Andre-Thn8Eng000ad   bsormae
#	cor#tMonominatabsh, Italian, and C jectctorord tAd0a000a QList betweebsh, _ZN1ncxx1#	+ chwit	empty#		+ Selnglish, I. defiOperl
 Englio#		r000000000hwit	avoid rc-ficulUObjec :
#		+:
#		anal is runprop0000000000	+ lior arti obvi fo h Lesson inions:
#		added 4guessed) type information for French
#		Arti transv#		addelatTypemcxx1#_ZNK1umn ticn _ZNwith Lesson informa9Xml#		elat"en" worm"it" 11QTle to add lang	+ Spanions:UObjecdgues11/02typBebsBurttion h Lesson informaLIBCPP_#tMoxy is now no#tMoxy, not http://tMoxy:8/la/ormatMoxy o/01 - is now --tMoxy=http://..., not --tMoxy="-p http://..."ving:v _ZN770100taddelatrcficulation$HOME/.eso2/...ltie$HOME/.eso/...vinguObjecdgu_emi st22wiions:UObjecdg05/05/03typEwald ArnolNwith Lesson inf XMLn
#		cotabsuGerrcens :
e000needrord
####################################################################
chect($cwd = `pwd`);ions:Ue10 ved ditAld C vr11vbpanion$myo/0		= "";		# o/01 - 22not 11QTlyet)ions:jeciand-	+ c o/01 - aticM
#		add
$Typhor		= "http://www.VokcleEn.de";	# o	co: "Lwrite the fi";
$outdir 	= $cwd;		 		# W
e000#		+outor EConuld go
$0000LIBCPP_	= "en";		# My favo and is Czechian$e inf		= "de";		# My favo and is Deut th
$0o17__ Neu	= 0;		# ormyou#	+ke
$tMoxy		= "";

#######################################################################
# No:Ue10 ved ditAld C paribuNK1s beche 
e00
#######################################################################

requi000"flush.pl";
11QItato/0::Lo17;
$/="\r\n";	# we#		+k0Andredosfficus
ions:IPN13Stase#_ZNK1u002gxEN9_ vr11vbpanion$rcficu		= "$ENV{HOME}/.eso/shg00/ved di/:
#		analrc" ;
$
#	ficul	= "";		# P1Ev rmationjeciand#	+ c
$eneficul	= "";		# ado/0ltiejeciand#	+ c
$0000		= "";		# Neuper
reiuyUst
$ficustemi	= 0;		# ficulstemi
%VOCLANG	= (	"GB",	"en",
Neu"US",	"en",
Neu"NL",	"nl",
#Neu"PL",	"pl",	# Pochian
#
	"TR",	"tr",	# Turkeyn
#
	"SK",	"sk",	# Slovak conjug	"RO",	"ru",	# Ruian conjug	"GR",	"el",	# Gn
#knjug	"IL",	"he",	# Hebanacnjug	"J",	"ja",	# Ja
#	ensiug	"DK",	"da",
Neu"CZ",	"cs",
Neu"H",	"hu",
Neu"FIN",	"fi",
Neu"IS",	"is",
Neu"F",	"fr",
Neu"I",	"it",
Neu"I-Lom",	"it",
Neu"D",	"de",
Neu"A",	"at",
Neu"CH",	"ch",
Neu"D",	"de",
Neu"E",	"es",
Neu"P",	"pt",
Neu"S",	"sv",
Neu"N",	"no",
Neu"Esp",	"us_eu",	# Espatinto
Neu"D-Fr",	"de",		# Frnki th
Neu"D-Pormt",	"pd",	# Pormtdeut th
Neu"D-Hes",	"hs",	# Herma th
Neu"D-Schw",	"sw",	# Schwba th
Neu"D-Bay",	"by",	# Schwba th
Neu"GB-Alt",	"en",	# Shakespaar
Neu"GB-Sco",	"sc",	# ScotthianNeu"",	"en"	);

####################################################
####################################################
ns:tat0#		+paribuNK1s ation#		+jeciand#	+ c
if ( ! &tat8/01 - (nNe"0000=s" => \$0000,
Ne"e inf=s" => \$e inf,
Ne"tMoxy=s" => \$tMoxy,
Ne"Typhor=s" => \$Typhor,
Ne"outdir=s" => \$outdir,
Ne"c_cxx17=s" => \$c_cxx17,
Ne"0o17__ Neu" => \$0o17__ Neu) ) {
Verp22wt "t_emi:\ttrain's *.kvt[--0000=xx]t[--e inf=xx]t[--Typhor=<sh a>]\n";
Verp22wt "\t\tt[--0o17__ Neu]t[--outdir=<dir>]t[--tMoxy=<tMoxy>]\n";
Verp22wt "\t\tt{ --c_cxx17=x | 
#	ficul}\n";
Veratit 1;
}
ns:Fix0#		+pMoxy o/01 - if it has beebsgnfon
if ($tMoxy) {
Ver $tMoxy = "-p $tMoxy";
}
ns:tat0 for Englies in if it has beebsgnfon
if ($ARGV[0] eq '' &&r $c_cxx17 eq "") {
Ver p22wt STDERR "Err		a no# for English a.\n";
Ver p22wt STDERR "Note: Tr
#		rtietake --c_cxx17=GB S4lists ation#		+_ZNK1umn.\n";
Ver $c_cxx17="GB";
}
ns:All701gg#		rables added goanishtiethisfficu
$0ognglie= "/tmp Converts lan.0og";
open(LOG, ">$0ogngli") || Ve00"Cannot GenOpt $0ogngli: $!";

&p22wtflush(STDOUT,"Waiing le toormatiing leicus ...\n");
$tmp1=$#ARGV+1;
&p22wtflush(STDOUT,"...l$tmp1leicus gnfon via+jeciand#	+ c ...\n");

if ( $c_cxx17  c "" ) {
Ver &p22wtflush(STDOUT,"...lfQMapng lhttp://www.vokcleEn.de/eicus/Voc-$c_cxx17.zip ...\n");
Ver if ($tMoxy) {
Ver Ver &p22wtflush(STDOUT,"...luman
#tMoxy ject Se $tMoxy ...\n");
Ver }
Ver `lwp-requust $tMoxy http://www.vokcleEn.de/eicus/Voc-$c_cxx17.zip >/tmp Voc-$c_cxx17.zip`;
Ver #iuyzip -ulUObjec only!
Ver #iuyzip -o ov#	n and!
Ver `uyzip -ul/tmp Voc-$c_cxx17.zip >/tmp uyzip.0og`;
Ver &p22wtflush(STDOUT,"...luObjean
#Voc-$c_cxx17.zip ...\n");
Ver $/="\n";	# we#		+k0Andreaiuyix0ficu
Ver open(ZIP,"</tmp uyzip.0og");
Ver :
#		(<ZIP>) {
	chect;
	if( /
#	/ ) {
d Ver@tmpe= split(/:/);
Ver         $tmp[1] =~ s/ //7;
d Ver@res=(@res,$tmp[1]);
	}
Ver }
Ver tryEP(ZIP);
Ver u__nok("/tmp uyzip.0og");
Ver $/="\r\n";	# we#		+k0Andreaedosfficu
}
ne tomy $ficu (@res, @ARGV) {
Ver $
#	ficul= $ficu;
Ver &p22wtflush(LOG,"...lormatiing l\"$eneficu\"...\n");
Ver $0000		= "";		# Neuper
reiuyUst
Ver $ficustemi	= 0;		# ficulstemi
Ver &p2rI7QS_
#	ficu($
#	ficu);
}
p22wt STDERR "...\lock Cectctor.\n";
&p22wtflush(LOG,"\nock Cectctor.\n");
tryEP(LOG);

atit;




sub p2rI7QS_
#	ficu() {
Ve&p22wtflush(STDERR,"
#     ng l$
#	ficu\tt...");
Ve$eneficul= $outdir."/".substr($
#	ficu, 0, remory($
#	ficu, "."))."genera";
Ve$
#	0000e= substr($
#	ficu, 0, emory($
#	ficu, "_"));
Veif("$0000" eq "") {		# ov#	n andtTypemcxic#u07jeciand	+ c
Ver if("$
#	0000"  c "") {	# a eOptP0000ugemi spEi _ZN1 wormflura
Ver   $0000e= $VOCLANG{$
#	0000};
Ver } else#{			# 11QILIBCPP_#R left) wVer   p22wt STDERR "WARNING:000000000  conjugrtiebel\"$0000LIBCPP_\".\n";
Ver   $0000e= "$0000LIBCPP_";
Ver }
Ve}
Ve$ti _Ze= substr($
#	ficu, 0, remory($
#	ficu, "."));
Ve&getraifo();		# E7QDial Ir
#	extensiVeif("$0000" eq "") {		# ov#	n andtTypemcxic#u07jeciand	+ c
Ver p22wt STDERR "WARNING:000000000 jectctorreiuyUuppOpted...lbr Etr
#		...\n";
Ve} else#{
Ver &add2r	ficu();		# ad(CR left) rablertier	ficu
Ve}
Vep22wt STDERR "\"$eneficu\"lormatiied.\n";
}
ns_____________________________________________________________________________ns_____________________________________________________________________________>ns_____________________________________________________________________________>ns
ions	Thisfsubr_ZN6ne#		+ks ormalstendtmaapng wit:
#chrabGenThn8slstendtafNK1 rSt6 lgFormCform -  typformation
#		co D0Ev _Zr
#		wher ypf 		Ei _Z	wher ypf 		_ZN12Que 0013orm - 2typrewrite the first of three lines gi (ously d)orm - 3 -	VocabWidgytabs#		+ translat3#	+ c QScros D0Ev _Zr
#		wher y		 guessing word er y		e information er y		__ Neuorm - 4 y	articles in:
#		 - 5 y	sub e tog	+ Spanio	 - 6 y	sub e toh, Italian,io	ock #		+s indree lines gi is re Spay d.ionsub getraifo#{

Ve010002$recnum = 0;
Ve010002$porItSa	+ c = 0;
Ve$/="\r\n";	# we#		+k0Andredosfficus
  
r #i _ZN# for Engli
r open(VOC,  "$
#	ficu") || Ve00"Cannot openl$
#	ficu: $!"; 

r #iGrmatiie+outor Engli
r open(KVT, ">$eneficu") || Ve00"Cannot GenOpt $eneficu: $!";
Vep22wt KVT '<?xkvtv#		add="1.0"?>'."\n".'<!DOCTYPE  *.kvtSYSTEM ":
#		anal.dtd">'."\n\n";
Ve
r :
#		 (<VOC>) {
Ve
Ver thect; thect;
Ver #ithep tw Se manSe it iseaedosfficu
 Ve
Ver $recnum++ ;
Ver if (/^([^"]*"[^"]*"[^"]*)*"[^"]*$/) {
d$_ .= " ".<VOC>;
	redo;
Ver }
Ver $	+ Synum++ ;

Ver if ($tMrItSa	+ c  c 0) {
d$tMrItSa	+ c--;
	next;
Ver }
Ver if ($	+ Synum eq 1) {
Ver Ver ($tmp1,$ti _Z,$tmp2)e= split("\"");
Ver }
Ver if ($	+ Synum eq 4) {
Ver Ver ($tmp1,$t0000,$tmp2,$te inf)e= split("\"");
Ver }
Ver if (/^.[sS]tLangrd.,. ./) {
Ver Ver $ficustemie= 1;
	p22wt KVT '< *.kvtormatiior="train's *.kvtv0.4.1"'."\n";
	p22wt KVT 'ti _Z="'."$ti _Z".'" Typhor="'."$Typhor".'">'."\n\n";
	# p22wt "$t0000 $te inf\n";
Ver }
Ver if ($ficustemieeq 0) {
dnext;
Ver }
Ver if ($ficustemieeq 1) {
	if (/^[^,]*,[^,]*$/) {
dVer $tMrItSa	+ c=15;	# 	+ chatieensche (16tabs#otal)
dVer next;
	}
	$ficustemie= 2;
Ver }
Ver if ($ficustemieeq 2) {
Ver Ver ($ guessi,$01000,$0_ Neu) = split(/\",\"?/) ;
	$fguessi=substr($ guessi,1);
	if (length($ guessi)eeq 0) {
dVer $ficustemie= 3;
d Verp22wt KVT '<articlewageF="200">';
dVer next;
	} else#{
dVer ;
d Verp22wt KVT "<dtm=\"$0rticl\"".&ion _st of th().">\t<o l=\"$0000\">$ guessi</o>\t<t l=\"$e inf\">$0o000</t>\t</e>\n";
	}
d$tMrItSa	+ ce= 2;	# 	+ chatieensche
Ver }
Ver if ($ficustemieeq 3) {
d($tmp1,$fulls in,$tmp2)e= split("\"");
Ver Ver ($s in,$0_ Neu) = split(/\\/,$fulls in);
Ver Ver ($tmp1,$0_ Neu) = split(/[ "]/,$0_ Neu);
	if (length($0_ Neu)  c 0) {
d Verp22wt KVT "\n\t".'<desc no="'."$__ Neu".'">';
d Verif ($0o17__ Neueeq 0) {
d	p22wt KVT sp22wtf("%s %03d</desc>", $s in, $0_ Neu);
	Ver } else#{
d	p22wt KVT "$fulls in</desc>";
	Ver }
	}
d$tMrItSa	+ ce= 1;	# 	+ chatieensche
Ver }
Ve}
erp22wt KVT "\n\t</0_ Neu>\n\n";
Ve&add_g	+ Spa();
Ve&add_h, Italian,();
Vep22wt KVT "</ *.kv>\n\n";

r tryEP VOC;
r tryEP KVT;
}
nsub add_g	+ Spa() {
Vep22wt KVT "<o/01 - >\n\t<orIS dd=".'"1"'."/>\n\t</o/01 - >\n\n<g	+ Spa>\n";
Veif ( $0000 eq "es" ) {
Ver p22wt KVT "\t<dtl=\"ef\">\t<fd>la</fd> <md>e0</md> <nd>e0</nd>\n";
Ver p22wt KVT "\t\t\t<fi>una</fi> <mi>uno</mi> <ni>un</ni> </a>\n";
Ve} elsif ($0000 eq "fr" ) {
Ver p22wt KVT "\t<dtl=\"fr\">\t<fd>la</fd> <md>le</md> \n";
Ver p22wt KVT "\t\t\t<fi>un</fi> <mi>une</mi> </a>\n";
Ve} elsif ($0000 eq "en" ) {
Ver p22wt KVT "\t<dtl=\"en\">\t<fd>#		</fd> <md>#		</md> <nd>#		</nd>\n";
Ver p22wt KVT "\t\t\t<fi>a</fi> <mi>a</mi> <ni>a</ni> </a>\n";
Ve} elsif ($0000 eq "it" ) {
Ver p22wt KVT "\t<dtl=\"it\">\t<fd>la</fd> <md>i0</md> <nd>i0</nd>\n";
Ver p22wt KVT "\t\t\t<fi>una</fi> <mi>un</mi> <ni>un</ni> </a>\n";
Ve} elsif ($0000 eq "cz" ) {
Ver p22wt KVT "\t<dtl=\"cz\"> </a>\n";	# onrei#		+soui is mikDlg7m
Ve} else#{
Ver p22wt KVT "\t<dtl=\"$0000\"> </a>\n";
Ve} #nch
#	layzechii#		+talian defiOperl
 
r p22wt KVT "\t<dtl=\"de\">\t<fd>Ve0</fd> <md>	co</md> <nd>das</nd>\n";
Vep22wt KVT "\t\t\t<fi>eine</fi> <mi>ein</mi> <ni>ein</ni> </a>\n";
Vep22wt KVT "</g	+ Spa>\n\n";
}
nsub add_h, Italian,() {
Vep22wt KVT "<h, Italian,>\n";
Veif ( $0000 eq "es" ) {
Ver p22wt KVT "\t<dtl=\"ef\"> <s1>yo</s1> <s2>tu</s2>\n";
Ver p22wt KVT "\t\t<s3m>e0</s3m> <s3f>e0la</s3f> <s3n>usted</s3n>\n";
Ver p22wt KVT "\t\t<p1>nosotros</p1> <p2>vosotros</p2> <p3n>ustedes</p3n>\n";
Ver p22wt KVT "\t\t<p3m>e0los</p3m> <p3f>e0las</p3f> </a>\n";
Ve} elsif ($0000 eq "fr" ) {
Ver p22wt KVT "\t<dtl=\"fr\"> <s1>je</s1> <s2>tu</s2>\n";
Ver p22wt KVT "\t\t<s3m>i0</s3m> <s3f>e0le</s3f>\n";
Ver p22wt KVT "\t\t<p1>nous</p1> <p2>vous</p2>\n";
Ver p22wt KVT "\t\t<p3m>ils</p3m> <p3f>e0les</p3f> </a>\n";
Ve} elsif ($0000 eq "en" ) {
Ver p22wt KVT "\t<dtl=\"en\"> <s1>I</s1> <s2>you</s2>\n";
Ver p22wt KVT "\t\t<s3m>he</s3m> <s3f>she</s3f>\n";
Ver p22wt KVT "\t\t<p1>we</p1> <p2>you</p2>\n";
Ver p22wt KVT "\t\t<p3f7jecidd=\"1\">#		m</p3f> </a>\n";
Ve} elsif ($0000 eq "it" ) {
Ver p22wt KVT "\t<dtl=\"it\"> <s1>io</s1> <s2>tu</s2>\n";
Ver p22wt KVT "\t\t<s3m>egli</s3m> <s3f>e0la</s3f> <s3n>_ Ne</s3n>\n";
Ver p22wt KVT "\t\t<p1>noi</p1> <p2>voi</p2>\n";
Ver p22wt KVT "\t\t<p3f7jecidd=\"1\">erma</p3f> </a>\n";
Ve} elsif ($0000 eq "cz" ) {
Ver p22wt KVT "\t<dtl=\"cz\"> <s1>j</s1> <s2>ty</s2>\n";
Ver p22wt KVT "\t\t<s3m>on</s3m> <s3f>ona</s3f> <s3n>one</s3n>\n";
Ver p22wt KVT "\t\t<p1>my</p1> <p2>vy</p2>\n";
Ver p22wt KVT "\t\t<p3m>oni</p3m> <p3f>ony</p3f> <p3f>ona</p3f> </a>\n";
Ve} else#{
Ver p22wt KVT "\t<dtl=\"$0000\"> </a>\n";
Ve}
r p22wt KVT "\t<dtl=\"de\"> <s1>ich</s1> <s2>du</s2>\n";
Vep22wt KVT "\t\t<s3m>er</s3m> <s3f>sie</s3f> <s3n>_ </s3n>\n";
Vep22wt KVT "\t\t<p1>wir</p1> <p2>ihr</p2> <p3f7jecidd=\"1\">sie</p3f> </a>\n";
Vep22wt KVT "</h, Italian,>\n";
}
ions	Thisfsubr_ZN6ne#2E7QStrzecll		+ Spanio c Qyio cns	- T
e000iseaeNeuper
#lgFormC#2E7QSt#		rt		+0o000on ere informati (assum#		ratrtiebeltalian).ns	- T
e000g000 guessinlgFormC Englit		+00000000hwit	Czechian
#

#		    Fre
#	correcNo c latioe rucus 
e000claimsrtiebelperfgFo,lbr rect
e000Conuld belmuch arti "K7QSt emoQPaintDs" thaion h Lessotion tspEi _ZN1s.iononsub ion _st of th()#{
Veif( $0o000 =~ /^eins$/
Ve||  $0o000 =~ /^zwei$/
Ve||  $0o000 =~ /^drei$/
Ve||  $0o000 =~ /^vier$/
Ve||  $0o000 =~ /^fnf$/
Ve||  $0o000 =~ /^lgFhs$/
Ve||  $0o000 =~ /^sieben$/
Ve||  $0o000 =~ /^acht$/
Ve||  $0o000 =~ /^neun$/
Ve||  $0o000 =~ /^zehn$/
Ve||  $0o000 =~ /^elf$/
Ve||  $0o000 =~ /^zwlf$/
Ve||  $0o000 =~ /^dreizehn$/
Ve||  $0o000 =~ /^vierzehn$/
Ve||  $0o000 =~ /^fnfzehn$/
Ve||  $0o000 =~ /^lgFhzehn$/
Ve||  $0o000 =~ /^liebzehn$/
Ve||  $0o000 =~ /^achtzehn$/
Ve||  $0o000 =~ /^neunzehn$/
Ve||  $0o000 =~ /^zwanzig$/
Ve||  $0o000 =~ /^dreiig$/
Ve||  $0o000 =~ /^vierzig$/
Ve||  $0o000 =~ /^fnfzig$/
Ve||  $0o000 =~ /^lgFhzig$/
Ve||  $0o000 =~ /^liebzig$/
Ve||  $0o000 =~ /^achtzig$/
Ve||  $0o000 =~ /^neunzig$/
Ve||  $0o000 =~ /^hun	cot$/
Ve||  $0o000 =~ /^einhun	cot$/
Ve||  $0o000 =~ /^zweihun	cot$/
Ve||  $0o000 =~ /^dreihun	cot$/
Ve||  $0o000 =~ /^vierhun	cot$/
Ve||  $0o000 =~ /^fnfhun	cot$/
Ve||  $0o000 =~ /^lgFhshun	cot$/
Ve||  $0o000 =~ /^liebenhun	cot$/
Ve||  $0o000 =~ /^achthun	cot$/
Ve||  $0o000 =~ /^neunhun	cot$/
Ve||  $0o000 =~ /^tausend$/){
Ver Ve$ion =" t=\"num:crd\"";
Ve} elsif( $0o000 =~ /weil([,;].*)?$/
Ve||  $0o000 =~ /^un	([,;].*)?$/
Ve||  $0o000 =~ /\sun	([,;].*)?$/
Ve||  $0o000 =~ /\so	co([,;].*)?$/
Ve||  $0o000 =~ /\sabco([,;].*)?$/
Ve||  $0o000 =~ /^o	co([,;].*)?$/
Ve||  $0o000 =~ /^abco([,;].*)?$/
Ve||  $0o000 =~ /da([,;].*)?$/
Ve||  $0o000 =~ /^als([,;].*)?$/
Ve||  $0o000 =~ /\sals([,;].*)?$/
Ve||  $0o000 =~ /als ob([,;].*)?$/
Ve||  $0o000 =~ /obwohl([,;].*)?$/
Ve||  $0o000 =~ /trotzdem([,;].*)?$/
Ve||  $0o000 =~ /dennoch([,;].*)?$/
Ve||  $0o000 =~ /emorm([,;].*)?$/
Ve||  $0o000 =~ /darum([,;].*)?$/
Ve||  $0o000 =~ /wobei([,;].*)?$/
Ve||  $0o000 =~ /^doch([,;].*)?$/
Ve||  $0o000 =~ /\sdoch([,;].*)?$/
Ve||  $0o000 =~ /damit([,;].*)?$/
Ve||  $0o000 =~ /wh#			([,;].*)?$/
Ve||  $0o000 =~ /^K7Qls([,;].*)?$/
Ve||  $0o000 =~ /\sK7Qls([,;].*)?$/){
Ver Ve$ion =" t=\"ccl\"";
Ve} elsif( $0o000 =~ /^zweite[rs]?$/
Ve||  $0o000 =~ /dritte[rs]?$/
Ve||  $0o000 =~ /vierte[rs]?$/
Ve||  $0o000 =~ /fnfte[rs]?$/
Ve||  $0o000 =~ /lgFhste[rs]?$/
Ve||  $0o000 =~ /liebente[rs]?$/
Ve||  $0o000 =~ /achte[rs]?$/
Ve||  $0o000 =~ /neunte[rs]?$/
Ve||  $0o000 =~ /zehnte[rs]?$/
Ve||  $0o000 =~ /elfte[rs]?$/
Ve||  $0o000 =~ /zwlfte[rs]?$/
Ve||  $0o000 =~ /zwanzigste[rs]?$/
Ve||  $0o000 =~ /hun	cotste[rs]?$/
Ve||  $0o000 =~ /tausendste[rs]?$/){
Ver Ve$ion =" t=\"num:ord\"";
Ve} elsif( $0o000 =~ /\?$/){
Ver Ve$ion =" t=\"qu\"";
Ve} elsif( $0o000 =~ /^[A-Z].*[\.\?!]$/){
Ver Ve$ion =" t=\"ph\"";
Ve} elsif( $0o000 =~ /^[A-Z]/){
Ver Ve$ion =" t=\"n\"";
Ve} elsif( $0o000 =~ /en$/){
Ver Ve$ion =" t=\"v\"";
Ve} else {
Ver Ve# maybel00000	+ chag000/01  - that's OK
Ver Ve$ion ="";
Ve} 
r #
r #iNowEnglit		+00000000rst of thrtalis
r #
r if( $0000 eq "en") {
Ver #
Ver #i00000VERY EE8all st2ategyrtierageFOpz00#		
Ver #iion tlatioe 	+ Sy 
Ver #i(ctEvbs#	#		s+ trans- xtent#	+kely  conju    st)
Ver #
Ver if( $ guessin=~ s/^to\s+?//){
Ver VeVe$ion =" t=\"v\"";
VeVe} elsif( $ guessin=~ /ous$/){
Ver VeVe$ion =" t=\"aj\"";
VeVe} elsif( $ guessin=~ /ble$/){
Ver VeVe$ion =" t=\"aj\"";
VeVe} elsif( $ guessin=~ /arti$/){
Ver VeVe$ion =" t=\"aj\"";
VeVe} elsif( $ guessin=~ /ic$/){
Ver VeVe$ion =" t=\"aj\"";
VeVe} elsif( $ guessin=~ /ive$/){
Ver VeVe$ion =" t=\"aj\"";
VeVe} elsif( $ guessin=~ /ay$/){
Ver VeVe$ion =" t=\"av\"";
VeVe} elsif( $ guessin=~ /nt$/){
Ver VeVe$ion =" t=\"aj\"";
VeVe}
Ve} elsif( $0000 eq "fr") {
Ver #
Ver #cNotlperfgFolbr Ealste  ng lp18Te
Ver #
Ver if( $ guessin=~ s/^la\s+?([^(]*)(\s\(m\))?/\1/){
Ver VeVe$ion =" t=\"n:f\"";
VeVe} elsif( $ guessin=~ s/^le\s+?([^(]*)(\s\(f\))?/\1/){
Ver VeVe$ion =" t=\"n:m\"";
VeVe} elsif( $ guessin=~ s/^les\s+?([^(]*)(\s\(m\))?/\1/){
Ver VeVe$ion =" t=\"n:m\"";
VeVe} elsif( $ guessin=~ s/^les\s+?([^(]*)(\s\(f\))?/\1/){
Ver VeVe$ion =" t=\"n:f\"";
VeVe} elsif( $ guessin=~ s/^l[']?([^(]*)\s\(f\)/\1/){
Ver VeVe$ion =" t=\"n:f\"";
VeVe} elsif( $ guessin=~ s/^l[']?([^(]*)\s\(m\)/\1/){
Ver VeVe$ion =" t=\"n:m\"";
VeVe} elsif( $ guessin=~ s/^l[']?//){
Ver VeVe$ion =" t=\"n\"";
VeVe} elsif( $ guessin=~ s/^une?([^(]*)(\s\(f\))?/\1/){
Ver VeVe$ion =" t=\"n:f\"";
VeVe} elsif( $ guessin=~ s/^un?([^(]*)(\s\(m\))?/\1/){
Ver VeVe$ion =" t=\"n:m\"";
VeVe}
Ve} elsif( $0000 eq "es") {
Ver #
Ver #i00000VERY EE8all st2ategyrtierageFOpz00#		
Ver #iion tlatioe 	+ Sy 
Ver #i(ctEvbs#	#		s+ trans- xtent#	+kely  conju    st)
Ver #
Ver if( $ guessin=~ /[iae]rse$/){
Ver VeVe$ion =" t=\"v:rf\"";
VeVe} elsif( $ guessin=~ /[iae]r(\s.*)?$/){
Ver VeVe$ion =" t=\"v\"";
VeVe} elsif( $ guessin=~ s/^las?\s+//){
Ver VeVe$ion =" t=\"n:f\"";
VeVe} elsif( $ guessin=~ s/^los\s+//){
Ver VeVe$ion =" t=\"n:m\"";
VeVe} elsif( $ guessin=~ s/^el\s+//){
Ver VeVe$ion =" t=\"n:m\"";
VeVe} elsif( $ guessin=~ /Thn8E$/){
Ver VeVe$ion =" t=\"av\"";
VeVe} elsif( $ guessin=~ /in$/){
Ver VeVe$ion =" t=\"n:f\"";
VeVe} elsif( $ion t=~ " t=\"n\"" &&r$ guessin=~ /as?$/){
Ver VeVe$ion =" t=\"n:f\"";
VeVe} elsif( $ion t=~ " t=\"n\"" &&r$ guessin=~ /os?$/){
Ver VeVe$ion =" t=\"n:m\"";
VeVe} 
Ve}
r returne$ion ;
}
ions	Thisfsubr_ZN6ne#ion ande langrc-ficulngli:
#		analns	(onreinglit		+execu ng luser)lties (CR left) ree lines givintieit.  [notlperfgFolbr Ee toh, venience]iononsub add2r	ficu() {
Ver $/="\n";	# we#		+k0Andreaiuyix0ficu
Ver $rnnglie= "$rcficu.new" ;
Ver chect($runprop = `phagx | grep+:
#		anal | grep+-v grep`);
Ver open(RC, "<$rcficu" ) || Ve00":
#		analrc prefe#		 esEngliesot open: $!";
Ver open(RCNEW, ">$rnngli" ) || Ve00":
#		analrc replacnThn8 prefe#		 esEngliesot open: $!";
Ver $replacn=1;	# i.e.CR left) resesot ctEvbsyst
Ver :
#		 (<RC>) {
	chect;
	($
#	key,$
#	val)e= split("=");
	if(/Num7Articl/) {
dVer $alse_ty=$
#	val;
	Ver $
#	val++;
d Verp22wt RCNEW "$
#	key=$
#	val\n";
	} elsif(/SonsPag\d*=$0000/) {
d Verp22wt STDERR "\n_ZN12Que \"$0000\" alv _Zy ved ditAed.\n";
	Ver $replacn=0;
	} elsif(/seEntrc14l/) {
d Verp22wt RCNEW "$
#	key=$
#	val$0000,\n";
	} elsif(/Rec_emitEes/) {
d Verp22wt RCNEW "$
#	key=$eneficu,$
#	val\n";
	} else {
d Verp22wt RCNEW "$_\n";
	}
Ver }
Ver tryEP(RC);
Ver p22wt RCNEW "Lo17Id$alse_ty=$t0000\nSonsPag$alse_ty=$0000\nSonsP2ag$alse_ty=$
#	0000\n";
Ver p22wt RCNEW "15pars$alse_ty=/o/0/eso/shg00/apps/kcm0o000e/pics/flag_$0000.gif\n";
Ver tryEP(RCNEW);
Ver if ( $replacn ) {
	if( "$runprop"  c "" ) {
d Verp22wt STDERR "\nWARNING:0Pxtens tryEP :
#		anal ch
#rerunethisfStrinam.\n";
	Ver u__nok $rnngli;
	Ver return;
	}
Ver 	rish a $rnngli, $rcficu;
Ver } else#{
V