X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition.pm;h=9a0f8b508e273c3357fd0cd40f9cf010e6f559b8;hb=10943ab0b79fbd489f6beb3b81a13ed8cbcfafcf;hp=fed22a3182f58439e7c664c7d3531a886b00b52d;hpb=65ed66b94aa5b05c0f64f6040642d41a980e95eb;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition.pm b/lib/Text/Tradition.pm index fed22a3..9a0f8b5 100644 --- a/lib/Text/Tradition.pm +++ b/lib/Text/Tradition.pm @@ -8,7 +8,7 @@ use Text::Tradition::Stemma; use Text::Tradition::Witness; use vars qw( $VERSION ); -$VERSION = "0.3"; +$VERSION = "0.5"; has 'collation' => ( is => 'ro', @@ -54,6 +54,13 @@ has 'stemmata' => ( default => sub { [] }, ); +has 'initialized' => ( + is => 'ro', + isa => 'Bool', + default => undef, + writer => '_init_done', + ); + # Create the witness before trying to add it around 'add_witness' => sub { my $orig = shift; @@ -101,7 +108,14 @@ Text::Tradition - a software model for a set of collated texts my @text_wits = $t->witnesses(); my $manuscript_a = $t->witness( 'A' ); - my $new_ms = $t->add_witness( 'sigil' => 'B' ); + + $t = Text::Tradition->new(); + $t->add_witness( 'sourcetype' => 'xmldesc', + 'file' => '/path/to/teitranscription.xml' ); + $t->add_witness( 'sourcetype => 'plaintext', 'sigil' => 'Q', + 'string' => 'The quick brown fox jumped over the lazy dogs' ); + ## TODO + $t->collate_texts; my $text_path_svg = $t->collation->as_svg(); ## See Text::Tradition::Collation for more on text collation itself @@ -226,7 +240,7 @@ if( $wit_a ) { is( $s->witness('X'), undef, "There is no witness X" ); ok( !exists $s->{'witnesses'}->{'X'}, "Witness key X not created" ); -my $wit_d = $s->add_witness( 'sigil' => 'D' ); +my $wit_d = $s->add_witness( 'sigil' => 'D', 'sourcetype' => 'collation' ); is( ref( $wit_d ), 'Text::Tradition::Witness', "new witness created" ); is( $wit_d->sigil, 'D', "witness has correct sigil" ); is( scalar $s->witnesses, 4, "object now has four witnesses" ); @@ -281,6 +295,7 @@ sub BUILD { $mod->can('parse')->( $self, $init_args ); } } + $self->_init_done( 1 ); return $self; } @@ -349,6 +364,17 @@ sub add_stemma { return $stemma; } +sub lemmatize { + my $self = shift; + unless( $self->has_language ) { + warn "Please set a language to lemmatize a tradition"; + return; + } + my $mod = "Text::Tradition::Language::" . $self->language; + load( $mod ); + $mod->can( 'lemmatize' )->( $self ); +} + no Moose; __PACKAGE__->meta->make_immutable;