issue#11: cds: changed __CDS_ guard prefix to CDSLIB_ for all .h files
[libcds.git] / tests / data / split.pl
1 #!/bin/perl\r
2 \r
3 my %words ;\r
4 \r
5 open( my $f, "text.txt" ) ;\r
6 binmode $f ;\r
7 \r
8 my $text = ''   ;\r
9 $text .= $_ while (<$f>) ;\r
10 close $f ;\r
11 \r
12 my @a = split /[^\w'-]/, $text ;\r
13 foreach my $w (@a) {\r
14         $words{$w} += 1 if $w ;\r
15 }\r
16 for (my $j = 1; $j < 30; ++$j ) {\r
17         for ( my $i = 0; $i + $j - 1 < @a; $i += 1 ) {\r
18                 my $s = '';\r
19                 for ( my $k = 0; $k < $j; ++$k ) {\r
20                         $s .= ' '.$a[$i+$k];\r
21                 }\r
22                 $s =~ /\s*(\S.+\S)\s*/;\r
23                 $s = $1 ;\r
24                 $s =~ s/\s\s+/ /g ;\r
25                 $words{$s} += 1 ;\r
26         }\r
27 }\r
28 \r
29 open (my $dst, ">dictionary.txt") ;\r
30 binmode $dst ;\r
31 \r
32 my $nCount = 0 ;\r
33 $nCount++ foreach (keys %words) ;\r
34 print $dst $nCount, "\n" ;\r
35 \r
36 print "Generate test dictionary...\n" ;\r
37 print $dst $_, "\n" foreach (keys %words)       ;\r
38 \r
39 close $dst  ;\r