/[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 10 - (hide annotations)
Wed May 25 23:27:35 2005 UTC (19 years ago) by dpavlin
File MIME type: text/plain
File size: 1103 byte(s)
add title rank to 3, small fix in index generation

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     print $t '@title='.$title."\n";
54 dpavlin 10 print $t 'qv='.join(",", @qv),"\n" if (@qv);
55     print $t "\n$trivia\n",
56     ("\t$title\n" x $title_rank),
57     "\t", join("\n\t", @qv), "\n";
58 dpavlin 6 close($t);
59     $trivia = '';
60     @qv = ();
61     $in = 0;
62     } else {
63     print "#$_\n";
64     }
65    
66     }
67    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26