/[bfilter]/trunk/bfilter.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

Contents of /trunk/bfilter.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Tue Sep 7 08:37:33 2004 UTC (19 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 1097 byte(s)
dump some statistics while creating index

1 #!/usr/bin/perl -w
2 #
3
4 use strict;
5 use locale;
6
7 # maximum entries
8 my $max = 0;
9 # minimum letters to search by
10 my $min_len = 3;
11
12 my $debug = 1;
13
14 sub print_file {
15 my $f = shift || return;
16 open(F, $f) || die "$f: $!";
17 while(<F>) {
18 print;
19 }
20 close(F);
21 }
22
23 print qq{
24 var headlines = Array();
25 };
26
27 my @part_arr;
28 my $last_part = '';
29 my $total = 0;
30
31 while(<STDIN>) {
32 chomp;
33
34 # escape single quote
35 s/'/\\'/g;
36
37 # split into min_len part and rest
38 my ($part,$rest) = ( substr($_,0,$min_len), substr($_,$min_len) );
39
40 # make part lowercase
41 $part = lc($part);
42
43 $last_part = $part if (! $last_part);
44
45 # new part?
46 if ($part ne $last_part) {
47 print STDERR $last_part,"\t",$#part_arr+1,"\n" if ($debug);
48 print "headlines['$last_part'] = Array(\n ",join(",\n ",@part_arr),");\n" if (@part_arr);
49 $total += $#part_arr;
50 @part_arr = ();
51 $last_part = $part;
52 }
53 push @part_arr, "'$_'";
54
55 # break out?
56 last if ($max && $total > $max);
57 }
58
59 print "headlines['$last_part'] = Array(\n ",join(",\n ",@part_arr),");\n" if (@part_arr);
60 print "var min_len = $min_len;\n";
61 print "// index elements: $total\n";

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26