Skip to content

Commit

Permalink
fix pod coverage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieren Diment committed Oct 18, 2010
1 parent 8d96847 commit 8daec23
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
25 changes: 25 additions & 0 deletions lib/Text/TranscriptMiner/Corpus.pm
Expand Up @@ -90,6 +90,13 @@ sub get_files_info {
return $data;
}

=head2 sub get_subnodes ($node [, $data])
Recursive function to get subnodesfrom this part $self->doctree and return as
an array ref.
=cut

sub get_subnodes {
my ($self, $node, $data) = @_;
$node ||= $self->doctree;
Expand All @@ -106,6 +113,12 @@ sub get_subnodes {
return $data;
}

=head2 sub search_for_subnodes ($tags, $doctree)
get all array ref of $tags present for this list of documents from $doctree
=cut

sub search_for_subnodes {
my ($self, $tags, $doctree) = @_;
croak "not an array reference" unless ref($tags) eq 'ARRAY';
Expand All @@ -120,13 +133,25 @@ sub search_for_subnodes {
return \@pages;
}

=head2 sub get_interviews ($docs)
for an array ref of docs, get all the applicable Test::TranscriptMiner::Interview objects and return in an array
=cut

sub get_interviews {
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;
}

=head2 sub get_all_tags_for_interviews($doctree)
get all the tags for a $doctree array of interviews
=cut

sub get_all_tags_for_interviews {
my ($self, $doctree) = @_;
$doctree ||= $self->doctree;
Expand Down
62 changes: 61 additions & 1 deletion lib/Text/TranscriptMiner/Corpus/Comparisons.pm
Expand Up @@ -3,12 +3,38 @@ use Moose;
extends 'Text::TranscriptMiner::Corpus';

use List::MoreUtils qw/any/;
use Tree::Simple::WithMetaData;
use File::Basename;

=head1 DESCRIPTION
Text::TranscriptMiner::Corpus;:Comparisons
utility functions for comparing different parts of a corpus
=head2 SUMMARY
groups, get_code_structure
=cut

=head2 groups
Sub for getting the grouping variables from the directory tree containing the corpus
=cut

sub groups {
my ($self) = @_;
return $self->_recursive_get_node_names(0);
}

=head2 _recursive_get_node_names
internal sub to do the work for C<groups>
=cut

sub _recursive_get_node_names {
my ($self, $level, $all_levels) = @_;
$all_levels ||=[];
Expand All @@ -20,7 +46,6 @@ sub _recursive_get_node_names {
if $t->getDepth() == $level;
}
);
$DB::single = 1 if $level == 1;
push @kids_names, $_->getNodeValue() for @this_level;
return $all_levels if !@kids_names;
@kids_names = _get_interviews_meta(@kids_names);
Expand All @@ -30,6 +55,12 @@ sub _recursive_get_node_names {
$self->_recursive_get_node_names(++$level, $all_levels);
}

=head2 sub _get_interviews_meta
internal only sub to get the metadata (person classification stuff) from the metadata embedded in the txt files filename.
=cut

sub _get_interviews_meta {
my (@names) = @_;
for (@names) {
Expand All @@ -43,13 +74,42 @@ sub _get_interviews_meta {
return @names;
}

=head2 _unique(@names)
internal sub to make a non-unique list unique.
=cut

sub _unique {
my (@names) = @_;
my %names;
$names{$_} = '' for @names;
return sort keys %names;
}

=head2 sub get_code_structure
Given a file location (or C<<$self->start_dir ../[basename of start_dir]_meta>>
by default), return a Tree::Simple::WithMetaData of all the wanted codes for
this analysis run.
The file structure is one code per line to reflect the tree structure:
- Code title {code_name}
- Another code title below this one {another_code_name}
- Code title up one {blah}
- Down one {blahblah}
- Down two {asdf}
- Up to to one above root {etc}
- Final code {final}
Delimiting of the tree level can be a single space per level or a single tab
character per level. You can mix the two but that would probably be silly.
TODO: Split this out into its own CPAN module.
=cut

sub get_code_structure {
my ($self, $structure_file) = @_;
if (!$structure_file) {
Expand Down
6 changes: 6 additions & 0 deletions lib/Text/TranscriptMiner/Document.pm
Expand Up @@ -100,6 +100,12 @@ sub get_this_tag {
return \@tagged_txt;
}

=head2 sub get_tags_for_docs(@docs)
get all tags for a list of files
=cut

sub get_tags_for_docs {
my ($self, @docs) = @_;
my $tags = {};
Expand Down

0 comments on commit 8daec23

Please sign in to comment.