requires( 'Moose::Role' );
requires( 'Set::Scalar' );
requires( 'Text::Tradition' );
-requires( 'Text::Tradition::Directory' );
requires( 'Text::Tradition::Error' );
requires( 'TryCatch' );
build_requires( 'Test::More::UTF8' );
+build_requires( 'Text::Tradition::Directory' );
&WriteAll;
use LWP::UserAgent;
use Set::Scalar;
use Text::Tradition::Analysis::Result;
-use Text::Tradition::Directory;
use Text::Tradition::Stemma;
use TryCatch;
Text::Tradition::Analysis - functions for stemma analysis of a tradition
+=head1 DESCRIPTION
+
+Text::Tradition is a library for representation and analysis of collated
+texts, particularly medieval ones. Where the Collation is the central
+feature of a Tradition, it may also have one or more stemmata associated
+with it, and these stemmata may be analyzed. This package provides the
+following modules:
+
+=over 4
+
+=item * L<Text::Tradition::HasStemma> - a role that will be composed into
+Text::Tradition objects, providing the ability for Text::Tradition::Stemma
+objects to be associated with them.
+
+=item * L<Text::Tradition::Stemma> - an object class that represents stemma
+hypotheses, both rooted (with a single archetype) and unrooted (e.g.
+phylogenetic trees).
+
+=item * Text::Tradition::Analysis (this package). Provides functions for
+the analysis of a given stemma against the collation within a given
+Tradition.
+
+=back
+
=head1 SYNOPSIS
use Text::Tradition;
$t->add_stemma( 'dotfile' => $stemmafile );
my $variant_data = run_analysis( $tradition );
- # Recalculate rank $n treating all orthographic variants as equivalent
- my $reanalyze = analyze_variant_location( $tradition, $n, 0, 'orthographic' );
-=head1 DESCRIPTION
-
-Text::Tradition is a library for representation and analysis of collated
-texts, particularly medieval ones. Where the Collation is the central feature of
-a Tradition, it may also have one or more temmata associated with it, and these stemmata may be analyzed. This package provides the following modules:
-
-=over 4
-
-=item * L<Text::Tradition::HasStemma> - a role that can be composed into Text::Tradition objects, providing the ability for Text::Tradition::Stemma objects to be associated with them.
-
-=item * L<Text::Tradition::Stemma> - an object class that represents stemma hypotheses, both rooted (with a single archetype) and unrooted (e.g. phylogenetic trees).
-
-=item * Text::Tradition::Analysis (this package). Provides functions for the analysis of a given stemma against the collation within a given Tradition.
-
-=back
-
=head1 SUBROUTINES
=head2 run_analysis( $tradition, %opts )
if( exists $opts{'calcdir'} ) {
$dir = delete $opts{'calcdir'}
} elsif ( exists $opts{'calcdsn'} ) {
+ eval { require Text::Tradition::Directory };
+ if( $@ ) {
+ throw( "Could not instantiate a directory for " . $opts{'calcdsn'}
+ . ": $@" );
+ }
$dir = Text::Tradition::Directory->new( dsn => $opts{'calcdsn'} );
}
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-my @exclude = qw/ Store Collation::Data TypeMap::Entry /;
-
my %mods;
map { $mods{$_} = 1 } all_modules();
-map { delete $mods{'Text::Tradition::'.$_} } @exclude;
if( -e 'MANIFEST.SKIP' ) {
open( SKIP, 'MANIFEST.SKIP' ) or die "Could not open skip file";
while(<SKIP>) {
$tradition->add_stemma( 'dotfile' => 't/data/besoin.dot' );
# Run the analysis of the tradition
-## TODO Make proper test db
-my $calcdsn = 'dbi:SQLite:dbname=t/data/analysis.db';
my %expected = (
2 => 'type1',
use Text::Tradition::Collation;
use Text::Tradition::Error;
use Text::Tradition::Witness;
-use Text::Tradition::User;
use TryCatch;
use vars qw( $VERSION );
# warn "Text::Tradition::Analysis not found. Disabling stemma analysis functionality";
# };
eval { with 'Text::Tradition::Language'; };
+eval { with 'Text::Tradition::Ownership'; };
has 'collation' => (
is => 'ro',
writer => '_init_done',
);
-has 'user' => (
- is => 'rw',
- isa => 'Text::Tradition::User',
- required => 0,
- predicate => 'has_user',
- clearer => 'clear_user',
- weak_ref => 1
- );
-
-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;
# If we are initializing an empty collation, don't assume that we
# have set a tradition.
delete $args{'init'};
- } elsif( $self->tradition->can('language') && !exists $args{'language'} ) {
+ } elsif( $self->tradition->can('language') && $self->tradition->has_language
+ && !exists $args{'language'} ) {
$args{'language'} = $self->tradition->language;
}
$reading = Text::Tradition::Collation::Reading->new(
like( $graphml, qr/digraph/, "Digraph declaration exists in GraphML" );
}
-# Now add a user, write to GraphML, and look at the output.
-unlike( $graphml, qr/testuser/, "Test user name does not exist in GraphML yet" );
-my $testuser = Text::Tradition::User->new(
- id => 'testuser', password => 'testpass' );
-is( ref( $testuser ), 'Text::Tradition::User', "Created test user object" );
-$testuser->add_tradition( $tradition );
-is( $tradition->user->id, $testuser->id, "Tradition assigned to test user" );
-$graphml = $c->as_graphml;
-like( $graphml, qr/testuser/, "Test user name now exists in GraphML" );
-
=end testing
=cut
};
}
- $graph_attributes{'user'} = sub {
- $self->tradition->user ? $self->tradition->user->id : undef
- };
+ if( $tmeta->has_method('user') ) {
+ $graph_attributes{'user'} = sub {
+ $self->tradition->user ? $self->tradition->user->id : undef
+ };
+ }
foreach my $datum ( sort keys %graph_attributes ) {
$graph_data_keys{$datum} = 'dg'.$gdi++;
$tradition->name( $graph_data->{'name'} );
my $use_version;
- my $tmeta = $tradition->meta;
- my $cmeta = $collation->meta;
foreach my $gkey ( keys %{$graph_data->{'global'}} ) {
my $val = $graph_data->{'global'}->{$gkey};
if( $gkey eq 'version' ) {
} else {
warn "Analysis module not installed; DROPPING stemmata";
}
- } elsif( $gkey eq 'language' ) {
- if( $tradition->can('language') ) {
- $tradition->language( $val );
- } else {
- warn "Morphology module not installed; DROPPING language";
- }
} elsif( $gkey eq 'user' ) {
# Assign the tradition to the user if we can
if( exists $opts->{'userstore'} ) {
} else {
warn( "DROPPING user assignment without a specified userstore" );
}
- } elsif( $tmeta->has_attribute( $gkey ) ) {
+ } elsif( $tradition->can( $gkey ) ) {
$tradition->$gkey( $val );
- } else {
+ } elsif( $collation->can( $gkey ) ) {
$collation->$gkey( $val );
+ } else {
+ warn( "DROPPING unsupported attribute $gkey" );
}
}
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-my @exclude = qw/ Store Collation::Data TypeMap::Entry /;
+my @exclude = qw/ Collation::Data /;
my %mods;
map { $mods{$_} = 1 } all_modules();
$graphml = $c->as_graphml;
like( $graphml, qr/digraph/, "Digraph declaration exists in GraphML" );
}
-
-# Now add a user, write to GraphML, and look at the output.
-unlike( $graphml, qr/testuser/, "Test user name does not exist in GraphML yet" );
-my $testuser = Text::Tradition::User->new(
- id => 'testuser', password => 'testpass' );
-is( ref( $testuser ), 'Text::Tradition::User', "Created test user object" );
-$testuser->add_tradition( $tradition );
-is( $tradition->user->id, $testuser->id, "Tradition assigned to test user" );
-$graphml = $c->as_graphml;
-like( $graphml, qr/testuser/, "Test user name now exists in GraphML" );
}
all_from( 'lib/Text/Tradition/Morphology.pm' );
requires( 'IPC::Run' );
requires( 'JSON' );
+requires( 'Lingua::Features' => '0.3.2' );
requires( 'Lingua::Features::Structure' );
+requires( 'Lingua::TagSet' => '0.3.3' );
requires( 'Lingua::TagSet::Multext' );
requires( 'Lingua::TagSet::TreeTagger::French' );
requires( 'Lingua::TagSet::TreeTagger::English' );
1;
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
1;
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
=head1 NAME
Text::Tradition::Language - add-on role to enable language awareness and
-morphology functions to a Text::Tradition object. See also
-L<Text::Tradition::Morphology> for individual reading morphologies.
+morphology functions to a Text::Tradition object. Please see
+L<Text::Tradition::Morphology> for more information on the morphology
+add-on distribution.
=head1 METHODS
1;
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
1;
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
=back
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
=back
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
=back
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
1;
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
1;
-=head1 LICENSE
-
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
1;
-=head1 LICENSE
+=head1 ACKNOWLEDGMENTS
-This package is free software and is provided "as is" without express
-or implied warranty. You can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=head1 AUTHOR
-
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
+The Perseus model and its dependents (currently Latin and Greek) draws its
+data from the ARTFL project at the University of Chicago. The module author
+wishes to thank Helma Dik in particular for her kind assistance.
\ No newline at end of file
=head1 NAME
-Text::Tradition::Morphology - add-on to associate lemma and part-of-speech
-information to Text::Tradition::Collation::Reading objects
+Text::Tradition::Morphology - morphology plugin for Text::Tradition
+
+=head1 DESCRIPTION
+
+The Text::Tradition::Morphology package enables lemma and part-of-speech
+information for traditions and their Reading objects. This distribution
+includes the L<Text::Tradition::Language> role for Traditions, the
+L<Text::Tradition::Morphology> role (this package) for Readings, and a set
+of Language::* modules for language-specific lemmatization.
+
+See L<Text::Tradition::Collation::Reading::Lexeme> for more about the
+morphology object structure.
=cut
}
};
-=head1 METHODS
+=head1 READING METHODS
Methods for the morphological information (if any) attached to readings.
A reading may be made up of multiple lexemes; the concatenated lexeme
If the language of the reading is set, this method will use the appropriate
Language model to determine the lexemes that belong to this reading. See
-L<Text::Tradition::lemmatize> if you wish to lemmatize an entire tradition.
+L<Text::Tradition::Language::lemmatize> if you wish to lemmatize an entire tradition.
=cut
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-my @exclude = qw/ Store Collation::Data TypeMap::Entry /;
-
my %mods;
map { $mods{$_} = 1 } all_modules();
-map { delete $mods{'Text::Tradition::'.$_} } @exclude;
if( -e 'MANIFEST.SKIP' ) {
open( SKIP, 'MANIFEST.SKIP' ) or die "Could not open skip file";
while(<SKIP>) {
requires( 'KiokuX::Model' );
requires( 'KiokuX::User::Util' );
requires( 'Moose' );
+requires( 'Moose::Role' );
requires( 'Safe::Isa' );
requires( 'TryCatch' );
requires( 'YAML::XS' );
extends 'KiokuX::Model';
+use vars qw/ $VERSION /;
+$VERSION = "1.0";
+
=head1 NAME
-Text::Tradition::Directory - a KiokuDB interface for storing and retrieving traditions
+Text::Tradition::Directory - a KiokuDB interface for storing and retrieving
+traditions and their owners
=head1 SYNOPSIS
=head1 DESCRIPTION
-Text::Tradition::Directory is an interface for storing and retrieving text traditions and all their data, including an associated stemma hypothesis. It is an instantiation of a KiokuDB::Model, storing traditions and associated stemmas by UUID.
+Text::Tradition::Directory is an interface for storing and retrieving text
+traditions and all their data, including an associated stemma hypothesis
+and a user who has ownership rights to the tradition data. It is an
+instantiation of a KiokuDB::Model, storing traditions and associated
+stemmas by UUID.
+
+The Text::Tradition::Directory package also includes the
+L<Text::Tradition::User> class for user objects, and the
+L<Text::Tradition::Ownership> role which extends the Text::Tradition class
+to handle user ownership.
=head1 ATTRIBUTES
or implied warranty. You can redistribute it and/or modify it under
the same terms as Perl itself.
-=head1 AUTHOR
+=head1 AUTHORS
+
+Tara L Andrews E<lt>aurum@cpan.orgE<gt> (initial release)
+
+Shadowcat Systems L<http://www.scsys.co.uk/> (user functionality; making it all work)
-Tara L Andrews E<lt>aurum@cpan.orgE<gt>
--- /dev/null
+package Text::Tradition::Ownership;
+
+use strict;
+use warnings;
+use Moose::Role;
+use Text::Tradition::User;
+
+requires 'throw';
+
+=head1 NAME
+
+Text::Tradition::Ownership - add-on role to enable Text::Tradition objects
+to have users who own them.
+
+=head1 METHODS
+
+=head2 user
+
+Accessor for the owner of the tradition.
+
+=head2 public
+
+Whether this tradition should be accessible (readonly) to anyone who is not
+the owner.
+
+=cut
+
+has 'user' => (
+ is => 'rw',
+ isa => 'Text::Tradition::User',
+ required => 0,
+ predicate => 'has_user',
+ clearer => 'clear_user',
+ weak_ref => 1
+ );
+
+has 'public' => (
+ is => 'rw',
+ isa => 'Bool',
+ required => 0,
+ default => sub { 0; },
+ );
+
+
+1;
+
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-my @exclude = qw/ Store Collation::Data TypeMap::Entry /;
+my @exclude = qw/ Store TypeMap::Entry /;
my %mods;
map { $mods{$_} = 1 } all_modules();
my $newt = Text::Tradition->new( 'input' => 'Self',
'file' => 't/data/florilegium_graphml.xml' );
+
+my $graphml = $newt->collation->as_graphml;
+unlike( $graphml, qr/testuser/, "Test user name does not exist in GraphML yet" );
my $fh = File::Temp->new();
my $file = $fh->filename;