requires( 'Moose' );
requires( 'Moose::Util::TypeConstraints' );
requires( 'StackTrace::Auto' );
-requires( 'Text::CSV_XS' );
+requires( 'Text::CSV' );
+requires( 'Text::TEI::Markup' );
requires( 'Throwable::X' );
requires( 'TryCatch' );
+requires( 'XML::Easy::Syntax' );
requires( 'XML::LibXML' );
requires( 'XML::LibXML::XPathContext' );
build_requires( 'Test::Warn' );
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
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" );
use File::Which;
use Graph;
use IPC::Run qw( run binary );
-use Text::CSV_XS;
+use Text::CSV;
use Text::Tradition::Collation::Reading;
use Text::Tradition::Collation::RelationshipStore;
use Text::Tradition::Error;
sub as_csv {
my( $self ) = @_;
my $table = $self->alignment_table;
- my $csv = Text::CSV_XS->new( { binary => 1, quote_null => 0 } );
+ my $csv = Text::CSV->new( { binary => 1, quote_null => 0 } );
my @result;
# Make the header row
$csv->combine( map { $_->{'witness'} } @{$table->{'alignment'}} );
# Now make the witness objects, and create their text sequences
foreach my $w ( grep { $_ !~ /_post$/ } keys %$edits_required ) {
print STDERR "Creating witness $w\n";
- my $witness_obj = $collation->tradition->add_witness( sigil => $w );
+ my $witness_obj = $collation->tradition->add_witness(
+ sigil => $w, sourcetype => 'collation' );
my $debug; # = $w eq 'Vb11';
my @ante_corr_seq = apply_edits( $collation, $edits_required->{$w}, $debug );
my @post_corr_seq = apply_edits( $collation, $edits_required->{$w."_post"}, $debug )
my $id= $wit_el->getAttribute( 'xml:id' );
my @sig_parts = $xpc->findnodes( './abbr/descendant::text()', $wit_el );
my $sig = _stringify_sigil( @sig_parts );
- $tradition->add_witness( sigil => $sig, source => $wit_el->toString() );
+ $tradition->add_witness( sigil => $sig, sourcetype => 'collation' );
$sigil_for{'#'.$id} = $sig; # Make life easy by keying on the ID ref syntax
}
# Note the sigla.
foreach my $sigil ( @{$opts->{'sigla'}} ) {
$ALL_SIGLA{$sigil} = 1;
- $tradition->add_witness( 'sigil' => $sigil );
+ $tradition->add_witness( sigil => $sigil, sourcetype => 'collation' );
}
# Now merge on the apparatus entries.
merge_stone_apparatus( $tradition->collation, $lineref_hash, $opts->{'file'} );
my @witnesses; # Keep the ordered list of our witnesses
my %ac_wits; # Track these for later removal
foreach my $sigil ( map { $_->{'witness'} } @{$table->{'alignment'}} ) {
- my $wit = $tradition->add_witness( 'sigil' => $sigil );
+ my $wit = $tradition->add_witness(
+ 'sigil' => $sigil, 'sourcetype' => 'collation' );
$wit->path( [ $c->start ] );
push( @witnesses, $wit );
my $aclabel = $c->ac_label;
# Add the witness if we don't have it already.
unless( $witnesses{$e->{'witness'}} ) {
- $tradition->add_witness( sigil => $e->{'witness'} );
+ $tradition->add_witness(
+ sigil => $e->{'witness'}, 'sourcetype' => 'collation' );
$witnesses{$e->{'witness'}} = 1;
}
$tradition->witness( $e->{'witness'} )->is_layered( 1 ) if $e->{'extra'};
foreach my $wit_el ( $xpc->findnodes( "//$LISTWIT/$WITNESS" ) ) {
my $sig = $wit_el->getAttribute( 'xml:id' );
my $source = $wit_el->toString();
- $tradition->add_witness( sigil => $sig, source => $source );
+ $tradition->add_witness( sigil => $sig, sourcetype => 'collation' );
}
map { $text->{$_->sigil} = [] } $tradition->witnesses;
use strict;
use warnings;
-use Text::CSV_XS;
+use Text::CSV;
=head1 NAME
$csv_options->{'quote_char'} = undef;
$csv_options->{'escape_char'} = undef;
}
- my $csv = Text::CSV_XS->new( $csv_options );
+ my $csv = Text::CSV->new( $csv_options );
my $alignment_table;
if( exists $opts->{'string' } ) {
# Set up the witnesses we find in the first line
my @witnesses;
my %ac_wits; # Track layered witness -> main witness mapping
+ my $aclabel = $c->ac_label;
foreach my $sigil ( @{$alignment_table->[0]} ) {
- my $wit = $tradition->add_witness( 'sigil' => $sigil );
- $wit->path( [ $c->start ] );
- push( @witnesses, $wit );
- my $aclabel = $c->ac_label;
if( $sigil =~ /^(.*)\Q$aclabel\E$/ ) {
+ # Sanitize the sigil name to an XML name
+ $sigil = $1 . '_layered';
$ac_wits{$sigil} = $1;
}
+ my $wit = $tradition->add_witness(
+ 'sigil' => $sigil, 'sourcetype' => 'collation' );
+ $wit->path( [ $c->start ] );
+ push( @witnesses, $wit );
+ my $aclabel = $c->ac_label;
}
# Save the original witness text sequences. Have to loop back through
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" );