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