line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CWB::CQP::More::Parallel; |
2
|
|
|
|
|
|
|
$CWB::CQP::More::Parallel::VERSION = '0.06'; |
3
|
1
|
|
|
1
|
|
1343
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use base 'CWB::CQP::More'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
148
|
|
8
|
|
|
|
|
|
|
use Try::Tiny; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=encoding utf-8 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
CWB::CQP::More::Parallel - CWP::CQP::More tweaked for parallel corpora |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use CWB::CQP::More::Parallel; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $cwb = CWB::CQP::More::Parallel->new( { utf8 => 1} ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
CWB::CQP::More prepared for parallel corpora. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
|
|
|
|
|
|
shift; # class |
31
|
|
|
|
|
|
|
my $ops = ref $_[0] eq "HASH" ? shift : {}; |
32
|
|
|
|
|
|
|
$ops->{parallel} = 1; |
33
|
|
|
|
|
|
|
__PACKAGE__->SUPER::new($ops, @_); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 change_corpus |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Change current active parallel corpus. Pass the corpus name as the argument. |
39
|
|
|
|
|
|
|
Automatically selects the target language corpus. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
B multilanguage corpora not yet supported. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub change_corpus($$) { |
46
|
|
|
|
|
|
|
my ($self, $cname) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $details = $self->corpora_details($cname); |
49
|
|
|
|
|
|
|
die "Can not find details for corpus $cname." unless defined $details; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# for now, use the first of the aligned corpus |
52
|
|
|
|
|
|
|
my ($aligned) = keys %{ $details->{attribute}{a} }; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
die "This does not seems a parallel corpus." unless defined $aligned; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$cname = uc $cname; |
57
|
|
|
|
|
|
|
$self->exec("$cname;"); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$self->annotation_show($aligned); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 cat |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This method uses the C method to return a result set. The first |
66
|
|
|
|
|
|
|
mandatory argument is the name of the result set. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
B Second and Third |
69
|
|
|
|
|
|
|
arguments are optional, and correspond to the interval of matches to |
70
|
|
|
|
|
|
|
return. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns empty list on any error. |
73
|
|
|
|
|
|
|
On success returns list of pairs. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub cat { |
78
|
|
|
|
|
|
|
my ($self, $id) = @_; # , $from, $to) = @_; |
79
|
|
|
|
|
|
|
# my $extra = ""; |
80
|
|
|
|
|
|
|
# $extra = "$from $to" if defined($from) && defined($to); |
81
|
|
|
|
|
|
|
my @ans; |
82
|
|
|
|
|
|
|
try { |
83
|
|
|
|
|
|
|
@ans = $self->exec("cat $id;"); #" $extra;"); |
84
|
|
|
|
|
|
|
} catch { |
85
|
|
|
|
|
|
|
@ans = (); |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my @fans; |
89
|
|
|
|
|
|
|
while (@ans) { |
90
|
|
|
|
|
|
|
my $left = shift @ans; |
91
|
|
|
|
|
|
|
my $right = shift @ans; |
92
|
|
|
|
|
|
|
push @fans, [$left,$right]; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
return @fans; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
CWB::CQP::More |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Copyright (C) 2014 by Alberto Manuel Brandão Simões |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
107
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
108
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
__END__ |