line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::YaTeA::TagSet; |
2
|
5
|
|
|
5
|
|
38
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
138
|
|
3
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
4001
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION=$Lingua::YaTeA::VERSION; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new |
9
|
|
|
|
|
|
|
{ |
10
|
4
|
|
|
4
|
1
|
14
|
my ($class,$file_path) = @_; |
11
|
4
|
|
|
|
|
9
|
my $this = {}; |
12
|
4
|
|
|
|
|
10
|
bless ($this,$class); |
13
|
4
|
|
|
|
|
28
|
$this->{CANDIDATES} = {}; |
14
|
4
|
|
|
|
|
11
|
$this->{PREPOSITIONS} = {}; |
15
|
4
|
|
|
|
|
12
|
$this->{DETERMINERS} = {}; |
16
|
4
|
|
|
|
|
11
|
$this->{COORDINATIONS} = {}; |
17
|
4
|
|
|
|
|
9
|
$this->{ANY} = {}; |
18
|
4
|
|
|
|
|
16
|
$this->loadTags($file_path); |
19
|
4
|
|
|
|
|
205
|
return $this; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub loadTags |
23
|
|
|
|
|
|
|
{ |
24
|
4
|
|
|
4
|
1
|
12
|
my ($this,$file_path) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
31
|
my $fh = FileHandle->new("<$file_path"); |
27
|
4
|
|
|
|
|
324
|
my $line; |
28
|
4
|
|
|
|
|
108
|
while ($line= $fh->getline) |
29
|
|
|
|
|
|
|
{ |
30
|
20
|
100
|
66
|
|
|
753
|
if(($line !~ /^\s*$/)&&($line !~ /^\s*#/)) # line is not empty nor commented |
31
|
|
|
|
|
|
|
{ |
32
|
16
|
|
|
|
|
46
|
$this->parseSubset($line); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub addTag |
39
|
|
|
|
|
|
|
{ |
40
|
56
|
|
|
56
|
1
|
100
|
my ($this,$subset,$tag) = @_; |
41
|
56
|
|
|
|
|
100
|
$this->getSubset($subset)->{$tag}++; |
42
|
56
|
|
|
|
|
99
|
$this->getSubset("ANY")->{$tag}++; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub getSubset |
46
|
|
|
|
|
|
|
{ |
47
|
7121
|
|
|
7121
|
1
|
11241
|
my ($this,$subset) = @_; |
48
|
7121
|
|
|
|
|
18033
|
return $this->{$subset}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub getTagList |
52
|
|
|
|
|
|
|
{ |
53
|
12
|
|
|
12
|
1
|
27
|
my ($this,$subset) = @_; |
54
|
12
|
|
|
|
|
28
|
return $this->getSubset($subset)->{"ALL"}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub existTag |
60
|
|
|
|
|
|
|
{ |
61
|
6997
|
|
|
6997
|
1
|
12586
|
my ($this,$subset,$tag) = @_; |
62
|
6997
|
100
|
|
|
|
12066
|
if (exists $this->getSubset($subset)->{$tag}) |
63
|
|
|
|
|
|
|
{ |
64
|
3727
|
|
|
|
|
9586
|
return 1; |
65
|
|
|
|
|
|
|
} |
66
|
3270
|
|
|
|
|
7879
|
return 0; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub parseSubset |
70
|
|
|
|
|
|
|
{ |
71
|
16
|
|
|
16
|
1
|
35
|
my ($this,$line) = @_; |
72
|
16
|
|
|
|
|
53
|
my $subset_name; |
73
|
|
|
|
|
|
|
my @tags; |
74
|
16
|
|
|
|
|
0
|
my $tag; |
75
|
16
|
50
|
|
|
|
121
|
if($line =~ s/\!\!([\S^=]+)\s*=\s*\(\(([^\!]+)\)\)\!\!\s*$/$2/) |
76
|
|
|
|
|
|
|
{ |
77
|
16
|
|
|
|
|
38
|
$subset_name = $1; |
78
|
16
|
|
|
|
|
84
|
@tags = split /\)\|\(/, $line; |
79
|
16
|
|
|
|
|
39
|
foreach $tag (@tags) |
80
|
|
|
|
|
|
|
{ |
81
|
56
|
|
|
|
|
102
|
$this->addTag($subset_name,$tag); |
82
|
|
|
|
|
|
|
} |
83
|
16
|
|
|
|
|
45
|
$this->makeALL($subset_name,\@tags); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
|
|
0
|
die "declaration d'etiquettes: erreur\n"; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub makeALL |
92
|
|
|
|
|
|
|
{ |
93
|
16
|
|
|
16
|
1
|
34
|
my ($this,$subset,$tags_a) = @_; |
94
|
16
|
|
|
|
|
36
|
${$this->{$subset}}{"ALL"} = $this->sort($tags_a); |
|
16
|
|
|
|
|
738
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub sort |
100
|
|
|
|
|
|
|
{ |
101
|
16
|
|
|
16
|
1
|
27
|
my ($this,$tags_a) = @_; |
102
|
16
|
|
|
|
|
78
|
my @tmp = reverse (sort @$tags_a); |
103
|
16
|
|
|
|
|
28
|
my $joint = "\)|\("; |
104
|
16
|
|
|
|
|
49
|
my $sorted_tag_list = join ($joint,@tmp); |
105
|
16
|
|
|
|
|
51
|
$sorted_tag_list = "\(\(" . $sorted_tag_list . "\)\)"; |
106
|
16
|
|
|
|
|
37
|
return $sorted_tag_list; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |