line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This file was automatically generated by SWIG (http://www.swig.org). |
2
|
|
|
|
|
|
|
# Version 3.0.12 |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Do not make changes to this file unless you know what you are doing--modify |
5
|
|
|
|
|
|
|
# the SWIG interface file instead. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Lingua::ZH::Jieba; |
8
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::VERSION = '0.004'; |
9
|
2
|
|
|
2
|
|
26563
|
use base qw(Exporter); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
193
|
|
10
|
2
|
|
|
2
|
|
15
|
use base qw(DynaLoader); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
498
|
|
11
|
|
|
|
|
|
|
package Lingua::ZH::Jiebac; |
12
|
|
|
|
|
|
|
$Lingua::ZH::Jiebac::VERSION = '0.004'; |
13
|
|
|
|
|
|
|
bootstrap Lingua::ZH::Jieba; |
14
|
|
|
|
|
|
|
package Lingua::ZH::Jieba; |
15
|
|
|
|
|
|
|
@EXPORT = qw(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# ---------- BASE METHODS ------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Lingua::ZH::Jieba; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub TIEHASH { |
22
|
0
|
|
|
0
|
|
0
|
my ($classname,$obj) = @_; |
23
|
0
|
|
|
|
|
0
|
return bless $obj, $classname; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
0
|
|
|
sub CLEAR { } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
0
|
|
|
sub FIRSTKEY { } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
0
|
|
|
sub NEXTKEY { } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub FETCH { |
33
|
0
|
|
|
0
|
|
0
|
my ($self,$field) = @_; |
34
|
0
|
|
|
|
|
0
|
my $member_func = "swig_${field}_get"; |
35
|
0
|
|
|
|
|
0
|
$self->$member_func(); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub STORE { |
39
|
0
|
|
|
0
|
|
0
|
my ($self,$field,$newval) = @_; |
40
|
0
|
|
|
|
|
0
|
my $member_func = "swig_${field}_set"; |
41
|
0
|
|
|
|
|
0
|
$self->$member_func($newval); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub this { |
45
|
0
|
|
|
0
|
0
|
0
|
my $ptr = shift; |
46
|
0
|
|
|
|
|
0
|
return tied(%$ptr); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# ------- FUNCTION WRAPPERS -------- |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package Lingua::ZH::Jieba; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
############# Class : Lingua::ZH::Jieba::vector_s ############## |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::vector_s; |
58
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::vector_s::VERSION = '0.004'; |
59
|
2
|
|
|
2
|
|
13
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
558
|
|
60
|
|
|
|
|
|
|
@ISA = qw( Lingua::ZH::Jieba ); |
61
|
|
|
|
|
|
|
%OWNER = (); |
62
|
|
|
|
|
|
|
%ITERATORS = (); |
63
|
|
|
|
|
|
|
sub new { |
64
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
65
|
0
|
|
|
|
|
0
|
my $self = Lingua::ZH::Jiebac::new_vector_s(@_); |
66
|
0
|
0
|
|
|
|
0
|
bless $self, $pkg if defined($self); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
*size = *Lingua::ZH::Jiebac::vector_s_size; |
70
|
|
|
|
|
|
|
*empty = *Lingua::ZH::Jiebac::vector_s_empty; |
71
|
|
|
|
|
|
|
*clear = *Lingua::ZH::Jiebac::vector_s_clear; |
72
|
|
|
|
|
|
|
*push = *Lingua::ZH::Jiebac::vector_s_push; |
73
|
|
|
|
|
|
|
*pop = *Lingua::ZH::Jiebac::vector_s_pop; |
74
|
|
|
|
|
|
|
*get = *Lingua::ZH::Jiebac::vector_s_get; |
75
|
|
|
|
|
|
|
*set = *Lingua::ZH::Jiebac::vector_s_set; |
76
|
|
|
|
|
|
|
sub DESTROY { |
77
|
0
|
0
|
|
0
|
|
0
|
return unless $_[0]->isa('HASH'); |
78
|
0
|
|
|
|
|
0
|
my $self = tied(%{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
79
|
0
|
0
|
|
|
|
0
|
return unless defined $self; |
80
|
0
|
|
|
|
|
0
|
delete $ITERATORS{$self}; |
81
|
0
|
0
|
|
|
|
0
|
if (exists $OWNER{$self}) { |
82
|
0
|
|
|
|
|
0
|
Lingua::ZH::Jiebac::delete_vector_s($self); |
83
|
0
|
|
|
|
|
0
|
delete $OWNER{$self}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub DISOWN { |
88
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
89
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
90
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub ACQUIRE { |
94
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
95
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
96
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
############# Class : Lingua::ZH::Jieba::vector_wordpos ############## |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::vector_wordpos; |
103
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::vector_wordpos::VERSION = '0.004'; |
104
|
2
|
|
|
2
|
|
11
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
512
|
|
105
|
|
|
|
|
|
|
@ISA = qw( Lingua::ZH::Jieba ); |
106
|
|
|
|
|
|
|
%OWNER = (); |
107
|
|
|
|
|
|
|
%ITERATORS = (); |
108
|
|
|
|
|
|
|
sub new { |
109
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
110
|
0
|
|
|
|
|
0
|
my $self = Lingua::ZH::Jiebac::new_vector_wordpos(@_); |
111
|
0
|
0
|
|
|
|
0
|
bless $self, $pkg if defined($self); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
*size = *Lingua::ZH::Jiebac::vector_wordpos_size; |
115
|
|
|
|
|
|
|
*empty = *Lingua::ZH::Jiebac::vector_wordpos_empty; |
116
|
|
|
|
|
|
|
*clear = *Lingua::ZH::Jiebac::vector_wordpos_clear; |
117
|
|
|
|
|
|
|
*push = *Lingua::ZH::Jiebac::vector_wordpos_push; |
118
|
|
|
|
|
|
|
*pop = *Lingua::ZH::Jiebac::vector_wordpos_pop; |
119
|
|
|
|
|
|
|
*get = *Lingua::ZH::Jiebac::vector_wordpos_get; |
120
|
|
|
|
|
|
|
*set = *Lingua::ZH::Jiebac::vector_wordpos_set; |
121
|
|
|
|
|
|
|
sub DESTROY { |
122
|
0
|
0
|
|
0
|
|
0
|
return unless $_[0]->isa('HASH'); |
123
|
0
|
|
|
|
|
0
|
my $self = tied(%{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
124
|
0
|
0
|
|
|
|
0
|
return unless defined $self; |
125
|
0
|
|
|
|
|
0
|
delete $ITERATORS{$self}; |
126
|
0
|
0
|
|
|
|
0
|
if (exists $OWNER{$self}) { |
127
|
0
|
|
|
|
|
0
|
Lingua::ZH::Jiebac::delete_vector_wordpos($self); |
128
|
0
|
|
|
|
|
0
|
delete $OWNER{$self}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub DISOWN { |
133
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
134
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
135
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub ACQUIRE { |
139
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
140
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
141
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
############# Class : Lingua::ZH::Jieba::vector_keyword ############## |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::vector_keyword; |
148
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::vector_keyword::VERSION = '0.004'; |
149
|
2
|
|
|
2
|
|
12
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
566
|
|
150
|
|
|
|
|
|
|
@ISA = qw( Lingua::ZH::Jieba ); |
151
|
|
|
|
|
|
|
%OWNER = (); |
152
|
|
|
|
|
|
|
%ITERATORS = (); |
153
|
|
|
|
|
|
|
sub new { |
154
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
155
|
0
|
|
|
|
|
0
|
my $self = Lingua::ZH::Jiebac::new_vector_keyword(@_); |
156
|
0
|
0
|
|
|
|
0
|
bless $self, $pkg if defined($self); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
*size = *Lingua::ZH::Jiebac::vector_keyword_size; |
160
|
|
|
|
|
|
|
*empty = *Lingua::ZH::Jiebac::vector_keyword_empty; |
161
|
|
|
|
|
|
|
*clear = *Lingua::ZH::Jiebac::vector_keyword_clear; |
162
|
|
|
|
|
|
|
*push = *Lingua::ZH::Jiebac::vector_keyword_push; |
163
|
|
|
|
|
|
|
*pop = *Lingua::ZH::Jiebac::vector_keyword_pop; |
164
|
|
|
|
|
|
|
*get = *Lingua::ZH::Jiebac::vector_keyword_get; |
165
|
|
|
|
|
|
|
*set = *Lingua::ZH::Jiebac::vector_keyword_set; |
166
|
|
|
|
|
|
|
sub DESTROY { |
167
|
0
|
0
|
|
0
|
|
0
|
return unless $_[0]->isa('HASH'); |
168
|
0
|
|
|
|
|
0
|
my $self = tied(%{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
169
|
0
|
0
|
|
|
|
0
|
return unless defined $self; |
170
|
0
|
|
|
|
|
0
|
delete $ITERATORS{$self}; |
171
|
0
|
0
|
|
|
|
0
|
if (exists $OWNER{$self}) { |
172
|
0
|
|
|
|
|
0
|
Lingua::ZH::Jiebac::delete_vector_keyword($self); |
173
|
0
|
|
|
|
|
0
|
delete $OWNER{$self}; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub DISOWN { |
178
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
179
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
180
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub ACQUIRE { |
184
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
185
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
186
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
############# Class : Lingua::ZH::Jieba::vector_word ############## |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::vector_word; |
193
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::vector_word::VERSION = '0.004'; |
194
|
2
|
|
|
2
|
|
15
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
555
|
|
195
|
|
|
|
|
|
|
@ISA = qw( Lingua::ZH::Jieba ); |
196
|
|
|
|
|
|
|
%OWNER = (); |
197
|
|
|
|
|
|
|
%ITERATORS = (); |
198
|
|
|
|
|
|
|
sub new { |
199
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
200
|
0
|
|
|
|
|
0
|
my $self = Lingua::ZH::Jiebac::new_vector_word(@_); |
201
|
0
|
0
|
|
|
|
0
|
bless $self, $pkg if defined($self); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
*size = *Lingua::ZH::Jiebac::vector_word_size; |
205
|
|
|
|
|
|
|
*empty = *Lingua::ZH::Jiebac::vector_word_empty; |
206
|
|
|
|
|
|
|
*clear = *Lingua::ZH::Jiebac::vector_word_clear; |
207
|
|
|
|
|
|
|
*push = *Lingua::ZH::Jiebac::vector_word_push; |
208
|
|
|
|
|
|
|
*pop = *Lingua::ZH::Jiebac::vector_word_pop; |
209
|
|
|
|
|
|
|
*get = *Lingua::ZH::Jiebac::vector_word_get; |
210
|
|
|
|
|
|
|
*set = *Lingua::ZH::Jiebac::vector_word_set; |
211
|
|
|
|
|
|
|
sub DESTROY { |
212
|
0
|
0
|
|
0
|
|
0
|
return unless $_[0]->isa('HASH'); |
213
|
0
|
|
|
|
|
0
|
my $self = tied(%{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
214
|
0
|
0
|
|
|
|
0
|
return unless defined $self; |
215
|
0
|
|
|
|
|
0
|
delete $ITERATORS{$self}; |
216
|
0
|
0
|
|
|
|
0
|
if (exists $OWNER{$self}) { |
217
|
0
|
|
|
|
|
0
|
Lingua::ZH::Jiebac::delete_vector_word($self); |
218
|
0
|
|
|
|
|
0
|
delete $OWNER{$self}; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub DISOWN { |
223
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
224
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
225
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub ACQUIRE { |
229
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
230
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
231
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
############# Class : Lingua::ZH::Jieba::Word ############## |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::Word; |
238
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::Word::VERSION = '0.004'; |
239
|
2
|
|
|
2
|
|
11
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
475
|
|
240
|
|
|
|
|
|
|
@ISA = qw( Lingua::ZH::Jieba ); |
241
|
|
|
|
|
|
|
%OWNER = (); |
242
|
|
|
|
|
|
|
%ITERATORS = (); |
243
|
|
|
|
|
|
|
*swig_word_get = *Lingua::ZH::Jiebac::Word_word_get; |
244
|
|
|
|
|
|
|
*swig_word_set = *Lingua::ZH::Jiebac::Word_word_set; |
245
|
|
|
|
|
|
|
*swig_offset_get = *Lingua::ZH::Jiebac::Word_offset_get; |
246
|
|
|
|
|
|
|
*swig_offset_set = *Lingua::ZH::Jiebac::Word_offset_set; |
247
|
|
|
|
|
|
|
*swig_length_get = *Lingua::ZH::Jiebac::Word_length_get; |
248
|
|
|
|
|
|
|
*swig_length_set = *Lingua::ZH::Jiebac::Word_length_set; |
249
|
|
|
|
|
|
|
sub new { |
250
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
251
|
0
|
|
|
|
|
0
|
my $self = Lingua::ZH::Jiebac::new_Word(@_); |
252
|
0
|
0
|
|
|
|
0
|
bless $self, $pkg if defined($self); |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub DESTROY { |
256
|
0
|
0
|
|
0
|
|
0
|
return unless $_[0]->isa('HASH'); |
257
|
0
|
|
|
|
|
0
|
my $self = tied(%{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
258
|
0
|
0
|
|
|
|
0
|
return unless defined $self; |
259
|
0
|
|
|
|
|
0
|
delete $ITERATORS{$self}; |
260
|
0
|
0
|
|
|
|
0
|
if (exists $OWNER{$self}) { |
261
|
0
|
|
|
|
|
0
|
Lingua::ZH::Jiebac::delete_Word($self); |
262
|
0
|
|
|
|
|
0
|
delete $OWNER{$self}; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub DISOWN { |
267
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
268
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
269
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub ACQUIRE { |
273
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
274
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
275
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
############# Class : Lingua::ZH::Jieba::KeywordExtractor ############## |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::KeywordExtractor; |
282
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::KeywordExtractor::VERSION = '0.004'; |
283
|
2
|
|
|
2
|
|
11
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
406
|
|
284
|
|
|
|
|
|
|
@ISA = qw( Lingua::ZH::Jieba ); |
285
|
|
|
|
|
|
|
%OWNER = (); |
286
|
|
|
|
|
|
|
%ITERATORS = (); |
287
|
|
|
|
|
|
|
sub new { |
288
|
0
|
|
|
0
|
|
0
|
my $pkg = shift; |
289
|
0
|
|
|
|
|
0
|
my $self = Lingua::ZH::Jiebac::new_KeywordExtractor(@_); |
290
|
0
|
0
|
|
|
|
0
|
bless $self, $pkg if defined($self); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
*_extract = *Lingua::ZH::Jiebac::KeywordExtractor__extract; |
294
|
|
|
|
|
|
|
sub DESTROY { |
295
|
2
|
100
|
|
2
|
|
1979
|
return unless $_[0]->isa('HASH'); |
296
|
1
|
|
|
|
|
3
|
my $self = tied(%{$_[0]}); |
|
1
|
|
|
|
|
4
|
|
297
|
1
|
50
|
|
|
|
5
|
return unless defined $self; |
298
|
1
|
|
|
|
|
3
|
delete $ITERATORS{$self}; |
299
|
1
|
50
|
|
|
|
5
|
if (exists $OWNER{$self}) { |
300
|
1
|
|
|
|
|
25999
|
Lingua::ZH::Jiebac::delete_KeywordExtractor($self); |
301
|
1
|
|
|
|
|
16
|
delete $OWNER{$self}; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
sub DISOWN { |
306
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
307
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
308
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub ACQUIRE { |
312
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
313
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
314
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
############# Class : Lingua::ZH::Jieba::Jieba ############## |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::Jieba; |
321
|
|
|
|
|
|
|
$Lingua::ZH::Jieba::Jieba::VERSION = '0.004'; |
322
|
2
|
|
|
2
|
|
14
|
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
505
|
|
323
|
|
|
|
|
|
|
@ISA = qw( Lingua::ZH::Jieba ); |
324
|
|
|
|
|
|
|
%OWNER = (); |
325
|
|
|
|
|
|
|
%ITERATORS = (); |
326
|
|
|
|
|
|
|
sub new { |
327
|
2
|
|
|
2
|
|
4
|
my $pkg = shift; |
328
|
2
|
|
|
|
|
4723615
|
my $self = Lingua::ZH::Jiebac::new_Jieba(@_); |
329
|
2
|
50
|
|
|
|
70
|
bless $self, $pkg if defined($self); |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
*_cut = *Lingua::ZH::Jiebac::Jieba__cut; |
333
|
|
|
|
|
|
|
*_cut_ex = *Lingua::ZH::Jiebac::Jieba__cut_ex; |
334
|
|
|
|
|
|
|
*_cut_all = *Lingua::ZH::Jiebac::Jieba__cut_all; |
335
|
|
|
|
|
|
|
*_cut_all_ex = *Lingua::ZH::Jiebac::Jieba__cut_all_ex; |
336
|
|
|
|
|
|
|
*_cut_for_search = *Lingua::ZH::Jiebac::Jieba__cut_for_search; |
337
|
|
|
|
|
|
|
*_cut_for_search_ex = *Lingua::ZH::Jiebac::Jieba__cut_for_search_ex; |
338
|
|
|
|
|
|
|
*insert_user_word = *Lingua::ZH::Jiebac::Jieba_insert_user_word; |
339
|
|
|
|
|
|
|
*_tag = *Lingua::ZH::Jiebac::Jieba__tag; |
340
|
|
|
|
|
|
|
*extractor = *Lingua::ZH::Jiebac::Jieba_extractor; |
341
|
|
|
|
|
|
|
sub DESTROY { |
342
|
2
|
100
|
|
2
|
|
1041
|
return unless $_[0]->isa('HASH'); |
343
|
1
|
|
|
|
|
3
|
my $self = tied(%{$_[0]}); |
|
1
|
|
|
|
|
3
|
|
344
|
1
|
50
|
|
|
|
5
|
return unless defined $self; |
345
|
1
|
|
|
|
|
3
|
delete $ITERATORS{$self}; |
346
|
1
|
50
|
|
|
|
5
|
if (exists $OWNER{$self}) { |
347
|
1
|
|
|
|
|
338020
|
Lingua::ZH::Jiebac::delete_Jieba($self); |
348
|
1
|
|
|
|
|
28
|
delete $OWNER{$self}; |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
} |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
sub DISOWN { |
353
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
354
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
355
|
0
|
|
|
|
|
0
|
delete $OWNER{$ptr}; |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub ACQUIRE { |
359
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
360
|
0
|
|
|
|
|
0
|
my $ptr = tied(%$self); |
361
|
0
|
|
|
|
|
0
|
$OWNER{$ptr} = 1; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# ------- VARIABLE STUBS -------- |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
package Lingua::ZH::Jieba; |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::KeywordExtractor; |
372
|
2
|
|
|
2
|
|
20
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
373
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
57
|
|
374
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
sub extract { |
377
|
1
|
|
|
1
|
|
930382
|
my ($self, $sentence, $top_n) = @_; |
378
|
|
|
|
|
|
|
|
379
|
1
|
|
|
|
|
432
|
my $words = $self->_extract($sentence, $top_n); |
380
|
|
|
|
|
|
|
|
381
|
1
|
|
|
|
|
7
|
for (@$words) { |
382
|
5
|
|
|
|
|
15
|
utf8::decode($_->[0]); |
383
|
|
|
|
|
|
|
} |
384
|
1
|
|
|
|
|
6
|
return $words; |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
package Lingua::ZH::Jieba::Jieba; |
389
|
2
|
|
|
2
|
|
157
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
29
|
|
390
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
391
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
7
|
|
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub _make_cut { |
394
|
4
|
|
|
4
|
|
9
|
my $want_position = shift; |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
return sub { |
397
|
12
|
|
|
12
|
|
10571
|
my ($self, $sentence, $opts) = @_; |
398
|
|
|
|
|
|
|
|
399
|
12
|
|
50
|
|
|
44
|
$opts ||= {}; |
400
|
12
|
|
|
|
|
26
|
my $no_hmm = $opts->{no_hmm}; |
401
|
12
|
|
|
|
|
29
|
my $cut_all = $opts->{cut_all}; |
402
|
|
|
|
|
|
|
|
403
|
12
|
|
|
|
|
25
|
my $words; |
404
|
|
|
|
|
|
|
|
405
|
12
|
100
|
|
|
|
34
|
if ($want_position) { |
406
|
6
|
100
|
|
|
|
19
|
if ($cut_all) { |
407
|
1
|
|
|
|
|
83
|
$words = $self->_cut_all_ex($sentence); |
408
|
|
|
|
|
|
|
} else { |
409
|
5
|
|
|
|
|
638
|
$words = $self->_cut_ex($sentence, !$no_hmm); |
410
|
|
|
|
|
|
|
} |
411
|
6
|
|
|
|
|
66
|
for (@$words) { |
412
|
24
|
|
|
|
|
69
|
utf8::decode($_->[0]); |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
} else { |
415
|
6
|
100
|
|
|
|
17
|
if ($cut_all) { |
416
|
1
|
|
|
|
|
81
|
$words = $self->_cut_all($sentence); |
417
|
|
|
|
|
|
|
} else { |
418
|
5
|
|
|
|
|
511
|
$words = $self->_cut($sentence, !$no_hmm); |
419
|
|
|
|
|
|
|
} |
420
|
6
|
|
|
|
|
34
|
for (@$words) { |
421
|
24
|
|
|
|
|
67
|
utf8::decode($_); |
422
|
|
|
|
|
|
|
} |
423
|
|
|
|
|
|
|
} |
424
|
|
|
|
|
|
|
|
425
|
12
|
|
|
|
|
52
|
return $words; |
426
|
4
|
|
|
|
|
30
|
}; |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
sub _make_cut_for_search { |
430
|
4
|
|
|
4
|
|
11
|
my $want_position = shift; |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
return sub { |
433
|
2
|
|
|
2
|
|
1722
|
my ($self, $sentence, $opts) = @_; |
434
|
|
|
|
|
|
|
|
435
|
2
|
|
50
|
|
|
10
|
$opts ||= {}; |
436
|
2
|
|
|
|
|
5
|
my $no_hmm = $opts->{no_hmm}; |
437
|
|
|
|
|
|
|
|
438
|
2
|
|
|
|
|
5
|
my $words; |
439
|
2
|
100
|
|
|
|
9
|
if ($want_position) { |
440
|
1
|
|
|
|
|
209
|
$words = $self->_cut_for_search_ex($sentence, !$no_hmm); |
441
|
1
|
|
|
|
|
9
|
for (@$words) { |
442
|
19
|
|
|
|
|
48
|
utf8::decode($_->[0]); |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
} else { |
445
|
1
|
|
|
|
|
253
|
$words = $self->_cut_for_search($sentence, !$no_hmm); |
446
|
1
|
|
|
|
|
9
|
for (@$words) { |
447
|
19
|
|
|
|
|
46
|
utf8::decode($_); |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
} |
450
|
2
|
|
|
|
|
9
|
return $words; |
451
|
4
|
|
|
|
|
21
|
}; |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
{ |
455
|
2
|
|
|
2
|
|
486
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
199
|
|
456
|
|
|
|
|
|
|
*cut = _make_cut(0); |
457
|
|
|
|
|
|
|
*cut_ex = _make_cut(1); |
458
|
|
|
|
|
|
|
*cut_for_search = _make_cut_for_search(0); |
459
|
|
|
|
|
|
|
*cut_for_search_ex = _make_cut_for_search(1); |
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
sub tag { |
463
|
1
|
|
|
1
|
|
1316
|
my ($self, $sentence) = @_; |
464
|
|
|
|
|
|
|
|
465
|
1
|
|
|
|
|
247
|
my $words = $self->_tag($sentence); |
466
|
1
|
|
|
|
|
8
|
for (@$words) { |
467
|
10
|
|
|
|
|
27
|
utf8::decode($_->[0]); |
468
|
|
|
|
|
|
|
} |
469
|
1
|
|
|
|
|
7
|
return $words; |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
package Lingua::ZH::Jieba; |
474
|
|
|
|
|
|
|
# ABSTRACT: Perl wrapper for CppJieba (Chinese text segmentation) |
475
|
2
|
|
|
2
|
|
38
|
use 5.010; |
|
2
|
|
|
|
|
35
|
|
476
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
38
|
|
477
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
37
|
|
478
|
2
|
|
|
2
|
|
17
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
7
|
|
479
|
|
|
|
|
|
|
|
480
|
2
|
|
|
2
|
|
533
|
use File::ShareDir qw(dist_file); |
|
2
|
|
|
|
|
4146
|
|
|
2
|
|
|
|
|
440
|
|
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
sub _shared_file { |
483
|
10
|
|
|
10
|
|
20
|
my $file = shift; |
484
|
10
|
|
|
|
|
27
|
return dist_file('Lingua-ZH-Jieba', $file); |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
my $default_dict_path = _shared_file('dict/jieba.dict.utf8'); |
487
|
|
|
|
|
|
|
my $default_user_dict_path = _shared_file('dict/user.dict.utf8'); |
488
|
|
|
|
|
|
|
my $default_hmm_path = _shared_file('dict/hmm_model.utf8'); |
489
|
|
|
|
|
|
|
my $default_idf_path = _shared_file('dict/idf.utf8'); |
490
|
|
|
|
|
|
|
my $default_stop_word_path = _shared_file('dict/stop_words.utf8'); |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
sub new { |
493
|
2
|
|
|
2
|
1
|
24096
|
my $pkg = shift; |
494
|
2
|
|
|
|
|
6
|
my $opts = shift; |
495
|
|
|
|
|
|
|
|
496
|
2
|
|
100
|
|
|
15
|
$opts //= {}; |
497
|
|
|
|
|
|
|
|
498
|
2
|
|
|
|
|
6
|
my $dict_path = $opts->{dict_path}; |
499
|
2
|
|
|
|
|
5
|
my $hmm_path = $opts->{hmm_path}; |
500
|
2
|
|
|
|
|
5
|
my $user_dict_path = $opts->{user_dict_path}; |
501
|
2
|
|
|
|
|
6
|
my $idf_path = $opts->{idf_path}; |
502
|
2
|
|
|
|
|
4
|
my $stop_word_path = $opts->{stop_word_path}; |
503
|
|
|
|
|
|
|
|
504
|
2
|
|
33
|
|
|
14
|
$dict_path //= $default_dict_path; |
505
|
2
|
|
33
|
|
|
14
|
$hmm_path //= $default_hmm_path; |
506
|
2
|
|
66
|
|
|
9
|
$user_dict_path //= $default_user_dict_path; |
507
|
2
|
|
33
|
|
|
11
|
$idf_path //= $default_idf_path; |
508
|
2
|
|
33
|
|
|
11
|
$stop_word_path //= $default_stop_word_path; |
509
|
|
|
|
|
|
|
|
510
|
2
|
|
|
|
|
20
|
return Lingua::ZH::Jieba::Jieba->new( |
511
|
|
|
|
|
|
|
$dict_path . "", |
512
|
|
|
|
|
|
|
$hmm_path . "", |
513
|
|
|
|
|
|
|
$user_dict_path . "", |
514
|
|
|
|
|
|
|
$idf_path . "", |
515
|
|
|
|
|
|
|
$stop_word_path . "" |
516
|
|
|
|
|
|
|
); |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
1; |