1 package Text::Tradition::HasStemma;
6 use Text::Tradition::Stemma;
10 Text::Tradition::HasStemma - add-on to associate stemma hypotheses to
11 Text::Tradition objects
15 It is often the case that, for a given text tradition, the order of copying
16 of the witnesses can or should be reconstructed (or at least the attempt
17 should be made.) This class is a role that can be applied to
18 Text::Tradition objects to record stemma hypotheses. See the documentation
19 for L<Text::Tradition::Stemma> for more information.
25 Return a list of all stemmata associated with the tradition.
29 Return the number of stemma hypotheses defined for this tradition.
33 Return the L<Text::Tradition::Stemma> object identified by the given index.
37 Delete all stemma hypotheses associated with this tradition.
43 isa => 'ArrayRef[Text::Tradition::Stemma]',
45 stemmata => 'elements',
46 _add_stemma => 'push',
48 stemma_count => 'count',
49 clear_stemmata => 'clear',
51 default => sub { [] },
55 =head2 add_stemma( $dotfile )
57 Initializes a Text::Tradition::Stemma object from the given dotfile,
58 and associates it with the tradition.
64 my $t = Text::Tradition->new(
65 'name' => 'simple test',
67 'file' => 't/data/simple.txt',
70 is( $t->stemma_count, 0, "No stemmas added yet" );
72 ok( $s = $t->add_stemma( dotfile => 't/data/simple.dot' ), "Added a simple stemma" );
73 is( ref( $s ), 'Text::Tradition::Stemma', "Got a stemma object returned" );
74 is( $t->stemma_count, 1, "Tradition claims to have a stemma" );
75 is( $t->stemma(0), $s, "Tradition hands back the right stemma" );
85 if( $opts{'dotfile'} ) {
86 open $stemma_fh, '<', $opts{'dotfile'}
87 or warn "Could not open file " . $opts{'dotfile'};
88 } elsif( $opts{'dot'} ) {
89 my $str = $opts{'dot'};
90 open $stemma_fh, '<', \$str;
93 binmode $stemma_fh, ':utf8';
94 my $stemma = Text::Tradition::Stemma->new(
95 'dot' => $stemma_fh );
96 $self->_add_stemma( $stemma ) if $stemma;
104 This package is free software and is provided "as is" without express
105 or implied warranty. You can redistribute it and/or modify it under
106 the same terms as Perl itself.
110 Tara L Andrews E<lt>aurum@cpan.orgE<gt>