fixed adding file problem
[c11concurrency-benchmarks.git] / gdax-orderbook-hpp / demo / dependencies / libcds-2.3.2 / test / stress / data / split.pl
diff --git a/gdax-orderbook-hpp/demo/dependencies/libcds-2.3.2/test/stress/data/split.pl b/gdax-orderbook-hpp/demo/dependencies/libcds-2.3.2/test/stress/data/split.pl
new file mode 100644 (file)
index 0000000..29887d9
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/perl\r
+\r
+my %words ;\r
+\r
+my $input_file = shift;\r
+my $output_file = shift;\r
+\r
+open( my $f, $input_file ) or die "Cannot open input file $input_file";\r
+binmode $f ;\r
+\r
+my $text = ''  ;\r
+$text .= $_ while (<$f>) ;\r
+close $f ;\r
+\r
+my @a = split /[^\w'-]/, $text ;\r
+foreach my $w (@a) {\r
+       $words{$w} += 1 if $w ;\r
+}\r
+for (my $j = 1; $j < 30; ++$j ) {\r
+       for ( my $i = 0; $i + $j - 1 < @a; $i += 1 ) {\r
+               my $s = '';\r
+               for ( my $k = 0; $k < $j; ++$k ) {\r
+                       $s .= ' '.$a[$i+$k];\r
+               }\r
+               $s =~ /\s*(\S.+\S)\s*/;\r
+               $s = $1 ;\r
+               $s =~ s/\s\s+/ /g ;\r
+               $words{$s} += 1 ;\r
+       }\r
+}\r
+\r
+open (my $dst, ">$output_file") or die "Cannot open output file $output_file";\r
+binmode $dst ;\r
+\r
+my $nCount = 0 ;\r
+$nCount++ foreach (keys %words) ;\r
+print $dst $nCount, "\n" ;\r
+\r
+print "Generate test dictionary $output_file ...\n" ;\r
+print $dst $_, "\n" foreach (keys %words)      ;\r
+\r
+close $dst  ;\r