Користувач:Дядько Ігор/Скрипти/Науковець
Зовнішній вигляд
#!/usr/bin/perl
#Зчитування словника
my %dict = ();
open(DIC, "dict.txt");
while ($line = <DIC>)
{
($orig, $trans) = split (/=/, $line,2);
$orig =~ s/^\s+//;
$orig =~ s/\s+$//;
$trans =~ s/^\s+//;
$trans =~ s/\s+$//;
$dict{ $orig } = $trans;
}
close(DIC);
# defaults
$name = "{{subst:PAGENAME}}";
open(FC, "scientist.txt");
while ($line = <FC>)
{
if ($line =~ m/^\{\{/)
{
print "skipping\n";
}
else
{
if ($line =~ m/^\}\}/)
{
print "skipping\n";
}
else
{
($tag, $value) = split(/=/,$line,2);
$tag =~ s/^\|//;
$tag =~ s/^\s+//;
$tag =~ s/\s+$//;
$value =~ s/^\s+//;
$value =~ s/\s+$//;
print "$tag $value \n";
$name = $value if ($tag eq "name");
$image = $value if ($tag eq "image");
$birth_date = $value if ($tag eq "birth_date");
$birth_place = $value if ($tag eq "birth_place");
$death_date = $value if ($tag eq "death_date");
$death_place = $value if ($tag eq "death_place");
$residence = $value if ($tag eq "residence");
$citizenship = $value if ($tag eq "citizenship");
$nationality = $value if ($tag eq "nationality");
$field = $value if ($tag eq "field");
$affiliation = $value if ($tag eq "work_institutions");
$alma_mater = $value if ($tag eq "alma_mater");
$known_for = $value if ($tag eq "known_for");
$advisor = $value if ($tag eq "doctoral_advisor");
$disciples = $value if ($tag eq "doctoral_students");
$awards = $value if ($tag eq "prizes");
}
}
}
close(FC);
# Обробка дат
@months = ("січня", "лютого", "березня", "квітня", "травня", "червня", "липня", "серпня", "вересня", "жовтня", "листопада", "грудня");
if (($birth_date =~ m/birth date/) || ($birth_date =~ m/Birth date/) )
{
($tag, $year, $month, $day) = split(/\|/,$birth_date,5);
$mn = @months[$month-1];
$birth_date = "[[$day $mn]] [[$year]]";
}
if (($death_date =~ m/death date/) || ($death_date =~ m/Death date/))
{
($tag, $year, $month, $day) = split(/\|/,$death_date,5);
$mn = @months[$month-1];
$death_date = "[[$day $mn]] [[$year]]";
}
# Переклад посилань
while ( my ($key, $value) = each(%dict) ) {
$birth_place =~ s/$key/$value/;
$death_place =~ s/$key/$value/;
$field =~ s/$key/$value/;
$awards =~ s/$key/$value/;
$alma_mater =~ s/$key/$value/;
$residence =~ s/$key/$value/;
$nationality =~ s/$key/$value/;
$citizenship =~ s/$key/$value/;
}
print<<EndCard
{{Картка:Науковець
| ім'я = $name
| портрет = Файл:$image
| зображення_розмір = $image_size
| зображення_підпис = $caption
| дата народження = $birth_date
| місце народження = $birth_place
| дата смерті = $death_date
| місце смерті = $death_place
| резиденція = $residence
| громадянство = $citizenship
| національність = $nationality
| галузь = $field
| заклад = $affiliation
| Alma Mater = $alma_mater
| відомий через = $known_for
| звання = $title
| ступінь = $degree
| керівник = $advisor
| учні = $disciples
| нагороди = $awards
| примітки = $notes
}}
EndCard
;