line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Mining::Corpus::Base; |
2
|
2
|
|
|
2
|
|
16
|
use base qw(Text::Mining::Base); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1056
|
|
3
|
|
|
|
|
|
|
use Class::Std; |
4
|
|
|
|
|
|
|
use Class::Std::Utils; |
5
|
|
|
|
|
|
|
use Archive::Tar; # http://search.cpan.org/~kane/Archive-Tar-1.46/lib/Archive/Tar.pm |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use warnings; |
8
|
|
|
|
|
|
|
use strict; |
9
|
|
|
|
|
|
|
use Carp; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use version; our $VERSION = qv('0.0.8'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
my %attribute_of : ATTR( get => 'attribute', set => 'attribute' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _default_corpus_path { |
17
|
|
|
|
|
|
|
my ( $self, $arg_ref ) = @_; |
18
|
|
|
|
|
|
|
return File::Spec->catfile( $self->get_root_dir(), |
19
|
|
|
|
|
|
|
'corpus_' . $self->get_corpus_id() ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub check_path { |
23
|
|
|
|
|
|
|
my ( $self ) = @_; |
24
|
|
|
|
|
|
|
my $path = $self->get_path(); |
25
|
|
|
|
|
|
|
if ( (-d $path) && (-w $path) ) { |
26
|
|
|
|
|
|
|
$self->_status( "Path exists: $path." ); |
27
|
|
|
|
|
|
|
} else { |
28
|
|
|
|
|
|
|
$self->_status( "Creating path: $path." ); |
29
|
|
|
|
|
|
|
mkdir( $path ); |
30
|
|
|
|
|
|
|
if ( (-d $path) && (-w $path) ) { |
31
|
|
|
|
|
|
|
$self->_status( "Sucess: $path." ); |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
$self->_status( "Failure: $path." ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_archive { |
41
|
|
|
|
|
|
|
my ( $self, $arg_ref ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $file_name = $arg_ref->{ file_name } ? $arg_ref->{ file_name } : ''; |
44
|
|
|
|
|
|
|
if ( $file_name ) { |
45
|
|
|
|
|
|
|
my $archive = Archive::Tar->new(); |
46
|
|
|
|
|
|
|
$archive->read( $file_name ); |
47
|
|
|
|
|
|
|
return $archive; |
48
|
|
|
|
|
|
|
} else { |
49
|
|
|
|
|
|
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
56
|
|
|
|
|
|
|
__END__ |