rdearman wrote:I just wanted to share a script I made for generating tons of cloze deletion cards with a perl script. You need a text file with each sentence on a new line then just run the script below on the file. You just feed it the sentence file as the first argument and the output csv file you want to create as the second argument. If you want to know how to
split a document on punctuation I covered that previously using libreoffice.
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
my $filename = $ARGV[0];
my $outfile = $ARGV[1];
# my $filename = "psicologia_italian2.txt";
# my $outfile = "cloze_it.csv";
open(my $fh, '<:encoding(UTF-8)', $filename) ;
open(my $ofh, '>:encoding(UTF-8)', $outfile);
while (my $row = <$fh>)
{
my $wordcount;
chomp $row;
my @words = $row =~ /\w+/g ;
$wordcount = scalar( @words );
for (my $a=0;$a<$wordcount;$a++)
{
print $ofh "{{c" . $a . "::" . $words[$a] . "}} " ;
}
print $ofh "\n";
}
print "done\n";
This will cloze delete
every word in the file. When you import the file into anki make sure you specify a tab delimited file, or it will not work.
Rdearman , I am very interested in this but I am an A0 at running scripts. “Just run the script below” means close to zero to me. This has happened a few times on the forum but this script interests me enough to shyly ask how to do that.
I’m not bad with using software (not clueless) but programming and scripts are a black hole for me.
Would you be so kind as to give me a quick guide? I guess it involves the command line thingy invoked from the windows button. I imagine I need to have my text file in the right place. Do I need to install anything - something Called Perl maybe?
I did have a quick look around YouTube for guidance but got lost quickly.
If you could give me a hand without too much trouble or point me in a direction where I could self teach I would be grateful.