This file is indexed.

/usr/share/perl5/Juman/Morpheme.pm is in libjuman-perl 7.0-3.4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# $Id: Morpheme.pm,v 1.7 2011/07/01 04:02:15 kawahara Exp $
package Juman::Morpheme;
require 5.004_04; # For base pragma.
use Carp;
use strict;
use base qw/ Juman::Katuyou Juman::KULM::Morpheme /;
use vars qw/ @ATTRS $ENCODING /;
use Encode;
=head1 NAME

Juman::Morpheme - 形態素オブジェクト in Juman

=head1 SYNOPSIS

  $m = new Juman::Morpheme( "解析 かいせき 解析 名詞 6 サ変名詞 2 * 0 * 0" );

=head1 DESCRIPTION

形態素の各種情報を保持するオブジェクト.

=head1 CONSTRUCTOR

=over 4

=item new ( SPEC, ID )

第1引数 I<SPEC> に Juman の出力を代入して呼び出すと,その行の内容を解
析し,相当する形態素オブジェクトを生成する.

=back

=cut

$ENCODING = $JUMAN::ENCODING ? $JUMAN::ENCODING : 'utf8';

@ATTRS = ( 'midasi',
	   'yomi',
	   'genkei',
	   'hinsi',
	   'hinsi_id',
	   'bunrui',
	   'bunrui_id',
	   'katuyou1',
	   'katuyou1_id',
	   'katuyou2',
	   'katuyou2_id',
	   'imis' );

sub new {
    my( $class, $spec, $id ) = @_;
    my $this = $id ? { id => $id } : {};

    my @value;
    my( @keys ) = @ATTRS;
    $spec =~ s/\s*$//;
    if( $spec =~ s/^\\  \\  \\  特殊 1 空白 6// ){
	@value = ( '\ ', '\ ', '\ ', '特殊', '1', '空白', '6' );
	push( @value, split( / /, $spec, scalar(@keys) - 7 ) );
    } else {
	@value = split( / /, $spec, scalar(@keys) );
    }
    while( @keys and @value ){
	my $key = shift @keys;
	$this->{$key} = shift @value;
    }

    bless $this, $class;
}

=head1 METHODS

=over 4

=item midasi

形態素の見出しを返す.

=cut
sub midasi {
    shift->{midasi};
}

=item yomi

形態素の読みを返す.

=cut
sub yomi {
    shift->{yomi};
}

=item genkei

形態素の原形を返す.

=cut
sub genkei {
    shift->{genkei};
}

=item hinsi

形態素の品詞を返す.

=cut
sub hinsi {
    shift->{hinsi};
}

=item hinsi_id

形態素の品詞番号を返す.

=cut
sub hinsi_id {
    shift->{hinsi_id} || undef;
}

=item bunrui

形態素の細分類を返す.

=cut
sub bunrui {
    shift->{bunrui};
}

=item bunrui_id

形態素の細分類番号を返す.

=cut
sub bunrui_id {
    shift->{bunrui_id};
}

=item katuyou1

形態素の活用型を返す.

=cut
sub katuyou1 {
    shift->{katuyou1};
}

=item katuyou1_id

形態素の活用型番号を返す.

=cut
sub katuyou1_id {
    shift->{katuyou1_id};
}

=item katuyou2

形態素の活用形を返す.

=cut
sub katuyou2 {
    shift->{katuyou2};
}

=item katuyou2_id

形態素の活用形番号を返す.

=cut
sub katuyou2_id {
    shift->{katuyou2_id};
}

=item imis

形態素の意味情報を返す.意味情報は,Juman に C<-e2> オプションを指定し
て実行すると得られる.

=cut
sub imis {
    shift->{imis};
}

=item push_imis

意味情報を追加する.

=cut
sub push_imis {
    my ($this, @imis) = @_;

    if ($this->{imis} eq 'NIL') {
	$this->{imis} = '"' . join(' ', @imis) . '"';
    }
    else {
	my $current_imis = $this->{imis};
	$current_imis =~ s/\"$//;

	$this->{imis} = $current_imis . ' ' . join(' ', @imis) . '"';
    }
}

=item repname

形態素の代表表記を返す.

=cut
sub repname {
    my ( $this ) = @_;
    my $pat = '代表表記';
    if( utf8::is_utf8( $this->midasi ) ){
	$pat = decode($ENCODING, $pat);
    }

    if ( defined $this->{imis} ){
	if ($this->{imis} =~ /$pat:([^\"\s]+)/){
	    return $1;
	}
    }
    return undef;
}

=item repnames

形態素の代表表記(曖昧性がある場合は「?」で連結)を返す.
引数(≠0)を与えると、音訓解消した場合の曖昧性は無視する.

=cut
sub repnames {
    my ( $this, $flag ) = @_;

    my $pat = '音訓解消';
    if( utf8::is_utf8( $this->midasi ) ){
	$pat = decode($ENCODING, $pat);
    }

    my ( @ret );
    my $org_rep = $this->repname();
    my $rep = $org_rep ? $org_rep : $this->make_repname(); # なければ作る
    push( @ret, $rep ) if $rep;
    if ( $org_rep && # 作った場合は同形異義語についても同じになるのでスキップ
	 # $flagが立っている場合は音訓解消した場合の曖昧性は無視
	 !( $flag && $this->spec =~ /<$pat>/ )) { 
	push @ret, $this->get_doukei_reps;
    }

    my ( %scan ); # 重複を削除
    join( '?', grep(!$scan{$_}++, sort @ret) );

}

=item get_doukei_reps

形態素の同型異義語の代表表記を返す.

=cut
sub get_doukei_reps {
    my ( $this ) = @_;

    my ( @reps );
    for my $doukei ( $this->doukei() ) { # 同形異義語 (@)
	my $rep = $doukei->repname();
	$rep = $doukei->make_repname() unless $rep;
	push( @reps, $rep ) if $rep;
    }

    return @reps;
}

=item make_repname

形態素の代表表記を作る.

=cut
sub make_repname {
    my ( $this ) = @_;
    my $basic_form_str = '基本形';
    if( utf8::is_utf8( $this->midasi ) ){
	$basic_form_str = decode( $ENCODING, $basic_form_str );
    }

    # 活用語なら基本形に戻す

    my $new_m = $this->change_katuyou2( $basic_form_str );
    if ( $new_m ){ # 活用語
	return $new_m->genkei . '/' . $new_m->yomi;
    }
    else {
	return $this->genkei . '/' . $this->yomi;
    }
}

=item kanou_dousi

形態素の可能動詞を返す.

=cut
sub kanou_dousi {
    my ( $this ) = @_;
    my $pat = '可能動詞';
    if( utf8::is_utf8( $this->midasi ) ) {
	$pat = decode($ENCODING, $pat);
    }

    if ( defined $this->{imis} ) {
	if ($this->{imis} =~ /$pat:([^\"\s]+)/) {
	    return $1;
 	}
    }
    return undef;
}

=item push_doukei( DOUKEI )

同形異義語 I<DOUKEI> を登録する.

=cut
sub push_doukei {
    my( $this, $doukei ) = @_;
    $this->{doukei} ||= [];
    push( @{$this->{doukei}}, $doukei );
}

=item doukei

形態素の同形異義語のリストを返す.

=cut
sub doukei {
    my( $this ) = @_;
    if( defined $this->{doukei} ){
	@{$this->{doukei}};
    } else {
	wantarray ? () : 0;
    }
}

=item id

コンストラクタを呼び出したときに指定した ID を返す.

=cut
sub id {
    my( $this ) = @_;
    $this->{id};
}

=item spec

形態素オブジェクトを文字列に変換する.

=cut
sub spec {
    my( $this ) = @_;
    sprintf( "%s\n", join( ' ', map( $this->{$_}, grep( defined $this->{$_}, @ATTRS ) ) ) );
}

1;

=back

=head1 SEE ALSO

=over 4

=item *

L<Juman::Katuyou>

=item *

L<Juman::KULM::Morpheme>

=back

=head1 AUTHOR

=over 4

=item
土屋 雅稔 <tsuchiya@pine.kuee.kyoto-u.ac.jp>

=cut

__END__
# Local Variables:
# mode: perl
# use-kuten-for-period: nil
# use-touten-for-comma: nil
# End: