Merge branch 'master' of github.com:tla/stemmatology
[scpubgit/stemmatology.git] / lib / Text / Tradition.pm
index 668383f..ce64e1d 100644 (file)
@@ -6,9 +6,10 @@ use Moose;
 use Text::Tradition::Collation;
 use Text::Tradition::Stemma;
 use Text::Tradition::Witness;
+use Text::Tradition::User;
 
 use vars qw( $VERSION );
-$VERSION = "0.3";
+$VERSION = "0.5";
 
 has 'collation' => (
     is => 'ro',
@@ -54,6 +55,28 @@ has 'stemmata' => (
        default => sub { [] },
        );
   
+has '_initialized' => (
+       is => 'ro',
+       isa => 'Bool',
+       default => undef,
+       writer => '_init_done',
+       ); 
+
+has 'user' => (
+    is => 'rw',
+    isa => 'Text::Tradition::User',
+    required => 0,
+    predicate => 'has_user',
+    clearer => 'clear_user',
+    );
+
+has 'public' => (
+    is => 'rw',
+    isa => 'Bool',
+    required => 0,
+    default => sub { 0; },
+    );
+
 # Create the witness before trying to add it
 around 'add_witness' => sub {
     my $orig = shift;
@@ -288,6 +311,7 @@ sub BUILD {
             $mod->can('parse')->( $self, $init_args );
         }
     }
+    $self->_init_done( 1 );
     return $self;
 }
 
@@ -356,6 +380,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;