source: gs2-extensions/ngramj/src/wiki/sortit.sl@ 27266

Last change on this file since 27266 was 25141, checked in by papitha, 12 years ago

NGRAMJ PERL MODULE ADDED /MAORI LANGUAGE GUESSING WORKING WELL!!

File size: 710 bytes
Line 
1%grams = ohash();
2setMissPolicy(%grams, { return @(); });
3
4$handle = openf(@ARGV[0]);
5$banner = readln($handle);
6readln($handle); # consume the ngram_count value
7
8while $text (readln($handle)) {
9 ($gram, $count) = split(' ', $text);
10
11 if (strlen($gram) <= 2 || $count > 20000) {
12 push(%grams[strlen($gram)], @($gram, $count));
13 }
14}
15closef($handle);
16
17sub sortTuple {
18 return $2[1] <=> $1[1];
19}
20
21println($banner);
22
23printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[1])));
24printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[2])));
25printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[3])));
26printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[4])));
Note: See TracBrowser for help on using the repository browser.