This file is indexed.

/usr/share/perl5/Juman/Hinsi.pm is in libjuman-perl 7.0-3.2.

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
# $Id: Hinsi.pm,v 1.3 2011/07/01 04:02:15 kawahara Exp $
package Juman::Hinsi;
require 5.004_04; # For base pragma.
use Carp;
use English qw/ $LIST_SEPARATOR $WARNING /;
use Juman::Grammar qw/ $HINSI $BUNRUI $TYPE $FORM /;
use strict;
use base qw/ Exporter /;
use vars qw/ @EXPORT_OK %EXPORT_TAGS $ENCODING /;
@EXPORT_OK = qw/ get_hinsi get_hinsi_id get_bunrui get_bunrui_id get_type get_type_id get_form get_form_id /;
%EXPORT_TAGS = ( all => [ @EXPORT_OK ] );

=head1 NAME

Juman::Hinsi - Juman 品詞体系を扱うライブラリ

=head1 SYNOPSIS

 use Juman::Hinsi qw/ get_hinsi_id /;
 $id = &get_hinsi_id( '名詞' );

=head1 DESCRIPTION

Juman 品詞体系の情報を得るための関数を提供するライブラリである.

=head1 FUNCTIONS

=over 4

=item get_hinsi ( ID )

品詞番号から品詞を得る

=cut

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

sub _zerop {
    ( $_[0] =~ /\D/ )? $_[0] eq '*' : $_[0] == 0;
}

sub _indexp {
    ( $_[0] !~ /\D/ and $_[0] >= 1 );
}

sub get_hinsi {
    if( @_ == 2 ){
	shift;
    } elsif( @_ != 1 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_hinsi(@_): requires an argument";
    }
    my( $x ) = @_;
    if( exists $HINSI->[0]->{$x} ){
	$x;
    } elsif( &_indexp($x) and defined $HINSI->[$x] ){
	$HINSI->[$x];
    } else {
	carp "Unknown hinsi ($x)" if $WARNING;
	undef;
    }
}

=item get_hinsi_id ( STR )

品詞から品詞番号を得る

=cut
sub get_hinsi_id {
    if( @_ == 2 ){
	shift;
    } elsif( @_ != 1 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_hinsi_id(@_): requires an argument";
    }
    my( $x ) = @_;

    if (utf8::is_utf8($x)) { # encode if the input has utf8_flag
	$x = Encode::encode($ENCODING, $x);
    }

    if( exists $HINSI->[0]->{$x} ){
	$HINSI->[0]->{$x};
    } elsif( &_indexp($x) and defined $HINSI->[$x] ){
	$x;
    } else {
	carp "Unknown hinsi id ($x)" if $WARNING;
	undef;
    }
}

=item get_bunrui ( HINSI, ID )

細分類番号から細分類を得る

=cut
sub get_bunrui {
    if( @_ == 3 ){
	shift;
    } elsif( @_ != 2 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_bunrui(@_): requires 2 arguments";
    }
    my( $hinsi, $x ) = @_;
    if( defined( $hinsi = &get_hinsi($hinsi) ) ){
	if( exists $BUNRUI->{$hinsi} ){
	    if( exists $BUNRUI->{$hinsi}->[0]->{$x} ){
		return $x;
	    } elsif( &_indexp($x) and defined $BUNRUI->{$hinsi}->[$x] ){
		return $BUNRUI->{$hinsi}->[$x];
	    }
	} elsif( &_zerop($x) ){
	    return '*';
	}
	carp "Unknown bunrui ($x)" if $WARNING;
    }
    undef;
}

=item get_bunrui_id ( HINSI, STR )

細分類から細分類番号を得る

=cut
sub get_bunrui_id {
    if( @_ == 3 ){
	shift;
    } elsif( @_ != 2 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_bunrui_id(@_): requires 2 arguments";
    }
    my( $hinsi, $x ) = @_;

    if (utf8::is_utf8($x)) { # encode if the input has utf8_flag
	$x = Encode::encode($ENCODING, $x);
    }

    if( defined( $hinsi = &get_hinsi($hinsi) ) ){
	if( exists $BUNRUI->{$hinsi} ){
	    if( exists $BUNRUI->{$hinsi}->[0]->{$x} ){
		return $BUNRUI->{$hinsi}->[0]->{$x};
	    } elsif( &_indexp($x) and defined $BUNRUI->{$hinsi}->[$x] ){
		return $x;
	    }
	} elsif( &_zerop($x) ){
	    return 0;
	}
	carp "Unknown bunrui id ($x)" if $WARNING;
    }
    undef;
}

=item get_type ( ID )

活用型番号から活用型を得る

=cut
sub get_type {
    if( @_ == 2 ){
	shift;
    } elsif( @_ != 1 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_type_id(@_): requires an argument";
    }
    my( $x ) = @_;
    if( &_zerop($x) ){
	'*';
    } elsif( exists $TYPE->[0]->{$x} ){
	$x;
    } elsif( &_indexp($x) and defined $TYPE->[$x] ){
	$TYPE->[$x]->[0];
    } else {
	carp "Unknown katuyou type ($x)" if $WARNING;
	undef;
    }
}

=item get_type_id ( STR )

活用型から活用型番号を得る

=cut
sub get_type_id {
    if( @_ == 2 ){
	shift;
    } elsif( @_ != 1 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_type_id(@_): requires an argument";
    }
    my( $x ) = @_;

    if (utf8::is_utf8($x)) { # encode if the input has utf8_flag
	$x = Encode::encode($ENCODING, $x);
    }

    if( &_zerop($x) ){
	0;
    } elsif( exists $TYPE->[0]->{$x} ){
	$TYPE->[0]->{$x};
    } elsif( &_indexp($x) and defined $TYPE->[$x] ){
	$x;
    } else {
	carp "Unknown katuyou id ($x)" if $WARNING;
	undef;
    }
}

=item get_form ( TYPE, ID )

活用型と活用形番号から活用形を得る

=cut
sub get_form {
    if( @_ == 3 ){
	shift;
    } elsif( @_ != 2 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_form(@_): requires 2 arguments";
    }
    my( $type, $x ) = @_;
    if( defined( $type = &get_type($type) ) ){
	if( $type eq '*' ){
	    if( &_zerop($x) ){
		return '*';
	    }
	} elsif( exists $FORM->{$type} ){
	    if( exists $FORM->{$type}->[0]->{$x} ){
		return $x;
	    } elsif( &_indexp($x) and defined $FORM->{$type}->[$x] ){
		return $FORM->{$type}->[$x]->[0];
	    }
	}
	carp "Unknown katuyou form ($x)" if $WARNING;
    }
    undef;
}

=item get_form_id ( TYPE, STR )

活用型と活用形から活用形番号を得る

=cut
sub get_form_id {
    if( @_ == 3 ){
	shift;
    } elsif( @_ != 2 ){
        local $LIST_SEPARATOR = ', ';
        croak "get_form_id(@_): requires 2 arguments";
    }
    my( $type, $x ) = @_;

    if (utf8::is_utf8($x)) { # encode if the input has utf8_flag
	$x = Encode::encode($ENCODING, $x);
    }

    if( defined( $type = &get_type($type) ) ){
	if( $type eq '*' ){
	    if( &_zerop($x) ){
		return 0;
	    }
	} elsif( exists $FORM->{$type} ){
	    if( exists $FORM->{$type}->[0]->{$x} ){
		return $FORM->{$type}->[0]->{$x};
	    } elsif( &_indexp($x) and defined $FORM->{$type}->[$x] ){
		return $x;
	    }
	}
	carp "Unknown katuyou form id ($x)" if $WARNING;
    }
    undef;
}

1;

=back

=head1 NOTES

C<Juman> オブジェクトのメソッドとして利用することもできる.

  Example:

     use Juman;
     $juman = new Juman();
     $id = $juman->get_hinsi_id( '名詞' );

=head1 SEE ALSO

=over 4

=item *

L<Juman>

=item *

L<Juman::Grammar>

=back

=head1 AUTHOR

=over 4

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

=back

=cut

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