Tara Andrews


Text::Tradition::Analysis - functions for stemma analysis of a tradition


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:

  • 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.

  • Text::Tradition::Stemma - an object class that represents stemma hypotheses, both rooted (with a single archetype) and unrooted (e.g. phylogenetic trees).

  • Text::Tradition::Analysis (this package). Provides functions for the analysis of a given stemma against the collation within a given Tradition.


  use Text::Tradition;
  use Text::Tradition::Analysis qw/ run_analysis analyze_variant_location /;
  my $t = Text::Tradition->new( 
    'name' => 'this is a text',
    'input' => 'TEI',
    'file' => '/path/to/tei_parallel_seg_file.xml' );
  $t->add_stemma( 'dotfile' => $stemmafile );

  my $variant_data = run_analysis( $tradition );


run_analysis( $tradition, %opts )

Runs the analysis described in analyze_variant_location on every location in the collation of the given tradition, with the given options. These include:

  • stemma_id - Specify which of the tradition's stemmata to use. Default is 0 (i.e. the first).

  • ranks - Specify a list of location ranks to analyze; exclude the rest.

  • merge_types - Specify a list of relationship types, where related readings should be treated as identical for the purposes of analysis.

  • exclude_type1 - Exclude those ranks whose groupings have only type-1 variants.

group_variants( $tradition, $rank, $lacunose, $transposed, $merge_relationship_types )

Groups the variants at the given $rank of the collation, treating any relationships in the set $merge_relationship_types as equivalent. $lacunose should be a reference to an array, to which the sigla of lacunose witnesses at this rank will be appended; $transposed should be a reference to a hash, wherein the identities of transposed readings and their relatives will be stored.

Returns a hash $group_readings where $rdg is attested by the witnesses listed in $group_readings->{$rdg}.

solve_variants( $calcdir, @groups )

Looks up the set of groups in the answers provided by the external graph solver service and returns a cleaned-up answer, adding the rank IDs back where they belong.

The answer has the form { "variants" => [ array of variant location structures ], "variant_count" => total, "conflict_count" => number of conflicts detected, "genealogical_count" => number of solutions found }

analyze_location ( $tradition, $graph, $location_hash )

Given the tradition, its stemma graph, and the solution from the graph solver, work out the rest of the information we want. For each reading we need missing, conflict, reading_parents, independent_occurrence, followed, not_followed, and follow_unknown. Alters the location_hash in place.

similar( $word1, $word2 )

Use Algorithm::Diff to get a sense of how close the words are to each other. This will hopefully handle substitutions a bit more nicely than Levenshtein.

wit_stringify( $groups )

Takes an array of witness groupings and produces a string like ['A','B'] / ['C','D','E'] / ['F']


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.


Tara L Andrews <aurum@cpan.org>