Skip to content

Commit

Permalink
get all tags for interview corpus
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieren Diment committed Oct 15, 2010
1 parent 4fed5f6 commit 666a70f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/Text/TranscriptMiner/Corpus.pm
Expand Up @@ -121,12 +121,29 @@ sub search_for_subnodes {
}

sub get_interviews {
my ($self, $start_dir, @docs) = @_;
@docs = map {Interview->new({file => Path::Class::Dir->new($start_dir)->file($_)}) } @docs;
my ($self, $start_dir, $docs) = @_;
my @docs = map {Interview->new({file => Path::Class::Dir->new($start_dir)->file($_)}) } @$docs;
@docs = grep {$_->txt} @docs;
return @docs;
}

sub get_all_tags_for_interviews {
my ($self, $doctree) = @_;
$doctree ||= $self->doctree;
my $data = $self->get_subnodes;
my @files = grep { -f $self->start_dir->file($_) } @$data;
my @docs = $self->get_interviews($self->start_dir, \@files);
my %tags;
foreach (@docs) {
$DB::single=1;
my %this_tags = %{$_->get_all_tags()};
foreach my $k (keys %this_tags) {
$tags{$k} += $this_tags{$k}
}
}
return \%tags;
}

__PACKAGE__->meta->make_immutable;

1;

0 comments on commit 666a70f

Please sign in to comment.