Skip to content

Instantly share code, notes, and snippets.

@dginev
Created May 22, 2014 15:46
Show Gist options
  • Save dginev/d1de6f8fd66a8a586e0e to your computer and use it in GitHub Desktop.
Save dginev/d1de6f8fd66a8a586e0e to your computer and use it in GitHub Desktop.
Paper Assigner for the NTCIR query brainstorming
use strict;
use warnings;
use File::Slurp qw(read_file);
use Archive::Zip qw(:CONSTANTS :ERROR_CODES);
my @names = sort qw/Andrea Michael Mihnea Prode Constantin Fulya Florian Deyan/;
my $needed_papers = 3 * scalar(@names);
my @papers = split("\n",read_file('/arXMLiv/NTCIR_files.txt'));
my @chosen = map {$papers[$_]} sort map {int(rand(100_000))} 1..$needed_papers;
my $zip_handle = Archive::Zip->new();
for my $i(0..$#names) {
for my $path(@chosen[(3*$i) .. (3*$i+2)]) {
$path =~ s/\/([^\/]+)\.html$//;
my $subdir = $1;
$zip_handle->addTree($path, "$names[$i]/$subdir");
}
}
unless ( $zip_handle->writeToFileNamed('NTCIR_query_documents.zip') == AZ_OK ) {
die 'write error';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment