line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Treex::Block::W2A::JA::ParseJDEPP; |
2
|
|
|
|
|
|
|
$Treex::Block::W2A::JA::ParseJDEPP::VERSION = '0.13095'; |
3
|
1
|
|
|
1
|
|
26106
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
74
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
848
|
use Moose; |
|
1
|
|
|
|
|
544744
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
8855
|
use Treex::Core::Common; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Treex::Tool::Parser::JDEPP; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Treex::Block::W2A::BaseChunkParser'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# we use kyoto-partial model as a default model (installed as default during jdepp installation) |
13
|
|
|
|
|
|
|
# other models should be trained through jdepp itself before using them |
14
|
|
|
|
|
|
|
has 'model_dir' => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => 'Str', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
default => 'data/models/parser/jdepp/kyoto-partial', |
19
|
|
|
|
|
|
|
documentation => 'path to the model relative to Treex resource_path', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has parser => ( is => 'rw' ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILD { |
25
|
|
|
|
|
|
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub process_start { |
31
|
|
|
|
|
|
|
my ($self) = @_; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#TODO: Model dir must be set outside Treex, via Jdepp itself -> fix this in the future! |
35
|
|
|
|
|
|
|
my $model_dir = $self->require_files_from_share( $self->model_dir ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $parser = Treex::Tool::Parser::JDEPP->new( model_dir => $model_dir ); |
38
|
|
|
|
|
|
|
$self->set_parser( $parser ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->SUPER::process_start(); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
return; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub parse_chunk { |
46
|
|
|
|
|
|
|
my ( $self, @a_nodes ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my @words = map { $_->form } @a_nodes; |
49
|
|
|
|
|
|
|
my @tags = map { $_->tag } @a_nodes; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my ( $parents_rf ) = $self->parser->parse_sentence( \@words, \@tags ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my @roots = (); |
54
|
|
|
|
|
|
|
foreach my $a_node (@a_nodes) { |
55
|
|
|
|
|
|
|
my $parent_index = shift @$parents_rf; |
56
|
|
|
|
|
|
|
if ($parent_index) { |
57
|
|
|
|
|
|
|
my $parent = $a_nodes[ $parent_index - 1 ]; |
58
|
|
|
|
|
|
|
$a_node->set_parent($parent); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
|
|
|
|
|
|
push @roots, $a_node; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
return @roots; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=pod |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding utf-8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Treex::Block::W2A::JA::ParseJDEPP |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
version 0.13095 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DECRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
JDEPP parser is used to determine the basic topology of a-layer trees. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SEE ALSO |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<Treex::Block::W2A::BaseChunkParser> base clase (see the C<reparse> parameter) |
90
|
|
|
|
|
|
|
L<JDEPP Home Page|http://www.tkl.iis.u-tokyo.ac.jp/~ynaga/jdepp/> more info on JDEPP parser |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |