1 package Text::Tradition::HasStemma;
6 use Text::Tradition::Stemma;
10 Text::Tradition::HasStemma - add-on to associate stemma hypotheses to Text::Tradition objects
14 It is often the case that, for a given text tradition, the order of copying of the witnesses can or should be reconstructed (or at least the attempt should be made.) This class is a role that can be applied to Text::Tradition objects to record stemma hypotheses. See the documentation for L<Text::Tradition::Stemma> for more information.
20 Return a list of all stemmata associated with the tradition.
24 Return the number of stemma hypotheses defined for this tradition.
28 Return the L<Text::Tradition::Stemma> object identified by the given index.
32 Delete all stemma hypotheses associated with this tradition.
38 isa => 'ArrayRef[Text::Tradition::Stemma]',
40 stemmata => 'elements',
41 _add_stemma => 'push',
43 stemma_count => 'count',
44 clear_stemmata => 'clear',
46 default => sub { [] },
50 =head2 add_stemma( $dotfile )
52 Initializes a Text::Tradition::Stemma object from the given dotfile,
53 and associates it with the tradition.
59 my $t = Text::Tradition->new(
60 'name' => 'simple test',
62 'file' => 't/data/simple.txt',
65 is( $t->stemma_count, 0, "No stemmas added yet" );
67 ok( $s = $t->add_stemma( dotfile => 't/data/simple.dot' ), "Added a simple stemma" );
68 is( ref( $s ), 'Text::Tradition::Stemma', "Got a stemma object returned" );
69 is( $t->stemma_count, 1, "Tradition claims to have a stemma" );
70 is( $t->stemma(0), $s, "Tradition hands back the right stemma" );
80 if( $opts{'dotfile'} ) {
81 open $stemma_fh, '<', $opts{'dotfile'}
82 or warn "Could not open file " . $opts{'dotfile'};
83 } elsif( $opts{'dot'} ) {
84 my $str = $opts{'dot'};
85 open $stemma_fh, '<', \$str;
88 binmode $stemma_fh, ':utf8';
89 my $stemma = Text::Tradition::Stemma->new(
90 'dot' => $stemma_fh );
91 $self->_add_stemma( $stemma ) if $stemma;
99 This package is free software and is provided "as is" without express
100 or implied warranty. You can redistribute it and/or modify it under
101 the same terms as Perl itself.
105 Tara L Andrews E<lt>aurum@cpan.orgE<gt>