On Wed, 18 Apr 2007, Mario Rizzi wrote:

> Hello.
> 
> I have a document which has about a hundred lines. Every line contains the
> three forms of English irregular verbs (I am a teacher of English). I would
> like to create some new documents, each of which should contain twenty-five
> lines picked at random from the original document, so that I can test my
> students on irregular verbs giving each of them a different test. Is there a
> way of doing it automatically?
> 
> Another nice thing I would like to do in the final documents is to cut out two
> of the forms in each line, leaving only one to start from. To make myself
> understood, the final test should look like this:
> 
> tab   tab gone
> take  tab     tab
> tab   brought tab
> and so on.
> 
> Again, is there a way of doing it in a few clicks?

Well, this Perl script might get you started. Save it into 
~/Library/Application Support/BBEdit/Unix Support/Unix Filters, then you 
can open your document, select all the lines in it, and run the filter on 
it. It will give you 25 random lines of your original 100, with one 
randomly-selected verb form remaining on each line. You could then do a 
save-a-copy, undo, and repeat. Or perhaps an AppleScript or Automator 
wizard could help you out with the repeating and saving part.

Here's the script:

#!/usr/bin/perl

# shuffle-verbs.pl
# Programmer: David Dierauer
# Created: Apr 18, 2007

use strict;
use warnings;
use List::Util qw/shuffle/;

my @lines = shuffle(<>);
for (my $i = 0; $i < 25; $i++) {
    my $line = $lines[$i];
    chomp $line;
    my @verb_forms = split /\t/, $line;
    my $keep = int rand 3;
    my $count = 0;
    foreach my $verb (@verb_forms) {
        $verb = '' unless $count++ == $keep;
    }
    print join("\t", @verb_forms) . "\n";
}

__END__

-- 
-David Dierauer
Software Engineer
[EMAIL PROTECTED]

-- 
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to