Rev 7693 | Rev 8633 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7693 | Rev 8618 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | use warnings; |
4 | use warnings; |
5 | use Encode; |
5 | use Encode; |
6 | 6 | ||
7 | use Exporter; |
7 | use Exporter; |
8 | our @ISA = 'Exporter'; |
8 | our @ISA = 'Exporter'; |
9 | our @EXPORT = ('hashdomain', 'listdomain', 'out','sortuniq', 'treate_accent', |
9 | our @EXPORT = ('hashdomain', 'listdomain', 'out', 'sortuniq', 'treate_accent', |
10 | 'treate_dict', 'treate_language', 'dictionnary', 'reverse_dic'); |
10 | 'treate_dict', 'treate_language', 'dictionnary', 'reverse_dic'); |
11 | 11 | ||
12 | sub canonify { my ($w)=@_; treate_accent(lc($w)) } |
12 | sub canonify { my ($w)=@_; treate_accent(lc($w)) } |
13 | 13 | ||
14 | sub treate_dict { my ($file) = @_; |
14 | sub treate_dict { my ($file) = @_; |
15 | my %ref = ( ) ; my $ref=\%ref |
15 | my %ref = ( ) ; my $ref=\%ref; |
- | 16 | my $text; |
|
16 | open IN, "$file"; |
17 | open IN, "$file"; |
17 | while (<IN>) { |
18 | while (<IN>) { |
18 | $text = $_ ; |
19 | $text = $_ ; |
19 | $text =~ s/\n +/\n/g; |
20 | $text =~ s/\n +/\n/g; |
20 | $text =~ s/\\//g; |
21 | $text =~ s/\\//g; |
Line 83... | Line 84... | ||
83 | } |
84 | } |
84 | 85 | ||
85 | ## reversing the domain tree |
86 | ## reversing the domain tree |
86 | 87 | ||
87 | sub hashdomain { my ($file)=@_; |
88 | sub hashdomain { my ($file)=@_; |
- | 89 | $/ = undef; |
|
88 | open IN, "$file"; |
90 | open IN, "$file"; |
89 | my %ref = ( ) ; my $ref=\%ref; |
91 | my %ref = ( ) ; my $ref=\%ref; |
90 | while (<IN>) { my $text=$_ ; $text=~ s/\\\n\s*//g; |
92 | while (<IN>) { my $text=$_ ; $text=~ s/\\\n\s*//g; |
91 | $text=~ s/\n\s+/\n/g; |
93 | $text=~ s/\n\s+/\n/g; |
92 | my @text= split("\n", $text); |
94 | my @text= split("\n", $text); |
Line 94... | Line 96... | ||
94 | next if !($line) ; |
96 | next if !($line) ; |
95 | $line =~ s/\s+//g; |
97 | $line =~ s/\s+//g; |
96 | my @cut=split(":", $line) ; |
98 | my @cut=split(":", $line) ; |
97 | if ($cut[1]) { |
99 | if ($cut[1]) { |
98 | my @son=split(',',$cut[1]); |
100 | my @son=split(',',$cut[1]); |
- | 101 | $ref->{'next'}{$cut[0]}=$cut[1]; |
|
99 | for my $s (@son) { |
102 | for my $s (@son) { |
100 | if ($ref |
103 | if ($ref->{'prev'}{$s}) { $ref->{'prev'}{$s} .= "," . $cut[0]} else {$ref->{'prev'}{$s} = $cut[0]} |
101 | } |
104 | } |
102 | } |
105 | } |
103 | } |
106 | } |
104 | } |
107 | } |
105 | close IN; |
108 | close IN; |