#!/usr/bin/env perl
use
5.014;
binmode
STDOUT,
":utf8"
;
die
"Supply a case\n"
if
(
scalar
@ARGV
< 1);
my
$case
=
$ARGV
[0];
my
$plural
=
defined
$ARGV
[1] ?
"plural"
: 0;
my
$arrow
= charnames::string_vianame(
"RIGHTWARDS ARROW"
);
sub
forvo {
my
(
$word
) =
@_
;
}
sub
opr {
my
(
$word
) =
@_
;
}
my
$rus
= Lingua::RU::Declension->new();
my
@out
;
for
(1..50) {
my
$noun
=
$rus
->choose_random_noun();
my
$adj
=
$rus
->choose_random_adjective();
my
$pronoun
=
$rus
->choose_random_pronoun();
my
$np
=
$rus
->decline_pronoun(
$pronoun
,
$noun
,
"nom"
,
$plural
);
my
$na
=
$rus
->decline_adjective(
$adj
,
$noun
,
"nom"
,
$plural
);
my
$nn
=
$rus
->decline_noun(
$noun
,
"nom"
,
$plural
);
my
$dp
=
$rus
->decline_pronoun(
$pronoun
,
$noun
,
$case
,
$plural
);
my
$da
=
$rus
->decline_adjective(
$adj
,
$noun
,
$case
,
$plural
);
my
$dn
=
$rus
->decline_noun(
$noun
,
$case
,
$plural
);
my
$front
=
"$np $na $nn ($case)"
;
my
$pro_url
= opr(
$pronoun
);
my
$adj_url
= opr(
$adj
);
my
$noun_url
= opr(
$noun
);
my
$answer
=
join
" "
, (
map
{; forvo(
$_
) } (
$dp
,
$da
,
$dn
));
my
$back
=
qq|$answer<br>$np $arrow $dp ($pro_url)<br>$na $arrow $da ($adj_url)<br>$nn $arrow $dn ($noun_url)|
;
push
@out
, [
$front
,
$back
];
}
my
$outname
=
$plural
?
"plural_${case}_flash.csv"
:
"${case}_flash.csv"
;
csv(
in
=> \
@out
,
out
=>
$outname
,
encoding
=>
"UTF-8"
);