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();
|
---|
2 | setMissPolicy(%grams, { return @(); });
|
---|
3 |
|
---|
4 | $handle = openf(@ARGV[0]);
|
---|
5 | $banner = readln($handle);
|
---|
6 | readln($handle); # consume the ngram_count value
|
---|
7 |
|
---|
8 | while $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 | }
|
---|
15 | closef($handle);
|
---|
16 |
|
---|
17 | sub sortTuple {
|
---|
18 | return $2[1] <=> $1[1];
|
---|
19 | }
|
---|
20 |
|
---|
21 | println($banner);
|
---|
22 |
|
---|
23 | printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[1])));
|
---|
24 | printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[2])));
|
---|
25 | printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[3])));
|
---|
26 | printAll(map({ return join(" ", $1); }, sort(&sortTuple, %grams[4])));
|
---|
Note:
See
TracBrowser
for help on using the repository browser.