/[pgestraier]/trunk/data/convert.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/data/convert.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (hide annotations)
Thu May 26 00:16:48 2005 UTC (19 years ago) by dpavlin
File MIME type: text/plain
File size: 1141 byte(s)
added size of each trivia to index (and back to output)

1 dpavlin 6 #!/usr/bin/perl -w
2    
3     use strict;
4    
5 dpavlin 10 # score for words in title
6     my $title_rank = 3;
7    
8 dpavlin 6 open(my $t, "gzip -cd trivia.list.gz |") || die "can't open trivia.list.gz: $!";
9    
10    
11     my $header = 1;
12     my $title = '';
13     my $in = 0;
14     my $trivia = '';
15     my @qv;
16    
17     sub qv {
18     my $t = shift || return;
19    
20     sub qv_print {
21     my $v = shift || return '';
22     $v =~ s/(.*)\s*,\s*(.+)/$2 $1/g;
23     push @qv, $v;
24     return '';
25     }
26     $t =~ s#([_'])([^\1]+?)\1 \(qv\)#qv_print($2)#ge;
27     }
28    
29     my $i = 0;
30    
31     while(<$t>) {
32     if (/^=====+/) {
33     $header = 0;
34     next;
35     }
36     next if $header;
37    
38     if (/^#\s+(.*)\s*$/) {
39     $title = $1;
40     print "# title=$title\n";
41     next;
42     } elsif (/^-\s(.*)\s*$/) {
43     $in = 1;
44     $trivia = "$1\n";
45     qv($1);
46     } elsif (/^\s\s(.*)\s*$/) {
47     $trivia .= "$1\n";
48     qv($1);
49     } elsif (/^$/ && $in) {
50     $i++;
51     print "$i ";
52     open(my $t, "> trivia/$i.est") || die "can't open $i.est: $!";
53 dpavlin 16 print $t '@title=', $title, "\n",
54     '@size=', length($trivia), "\n";
55 dpavlin 10 print $t 'qv='.join(",", @qv),"\n" if (@qv);
56     print $t "\n$trivia\n",
57     ("\t$title\n" x $title_rank),
58     "\t", join("\n\t", @qv), "\n";
59 dpavlin 6 close($t);
60     $trivia = '';
61     @qv = ();
62     $in = 0;
63     } else {
64     print "#$_\n";
65     }
66    
67     }
68    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26