1 package Text::Tradition;
3 use Text::Tradition::Witness;
4 use Text::Tradition::Collation;
9 isa => 'Text::Tradition::Collation',
15 isa => 'ArrayRef[Text::Tradition::Witness]',
17 all_options => 'elements',
20 option_count => 'count',
21 sorted_options => 'sort',
25 around BUILDARGS => sub {
29 # Now @_ contains the original constructor args. Make a
30 # collation argument and a witnesses argument.
32 my %member_objects = ( 'collation' => undef,
35 if( exists $init_args{'witnesses'} ) {
36 # We got passed an uncollated list of witnesses. Make a
37 # witness object for each witness, and then send them to the
40 foreach my $wit ( %{$init_args{'witnesses'}} ) {
41 # Each item in the list is either a string or an arrayref.
42 # If it's a string, it is a filename; if it's an arrayref,
43 # it is a tuple of 'sigil, file'. Handle either case.
45 if( ref( $wit ) eq 'ARRAY' ) {
46 $args = { 'sigil' => $wit->[0],
47 'file' => $wit->[1] };
49 $args = { 'sigil' => chr( $autosigil+65 ),
53 push( @{$member_objects{'witnesses'}},
54 Text::Tradition::Witness->new( $args ) );
55 # Now how to collate these?
58 $member_objects{'collation'} =
59 Text::Tradition::Collation->new( %init_args );
60 @{$member_objects{'witnesses'}} =
61 $member_objects{'collation'}->create_witnesses();
64 return $class->$orig( %member_objects );
67 # The user will usually be instantiating a Tradition object, and
68 # examining its collation. The information about the tradition can
69 # come via several routes:
70 # - graphML from CollateX or elsewhere, standalone
71 # - TEI parallel segmentation
72 # - Leuven-style spreadsheet of variants, converted to CSV, plus base text
73 # - apparatus pulled from CTE, plus base text
74 # From this we should be able to get basic witness information.
76 # Alternatively the user can just give us the uncollated texts. Then
77 # instead of passing a collation, s/he is passing a set of witnesses
78 # from which we will generate a collation. Those witnesses can be in
79 # plaintext or in TEI with certain constraints adopted.
81 # So the constructor for a tradition needs to take one of these infosets,
82 # and construct the collation and the witness objects.
85 __PACKAGE__->meta->make_immutable;