Commit | Line | Data |
---|---|---|
a5d53377 | 1 | #!/usr/bin/env perl |
2 | ||
3 | use lib 'lib'; | |
4 | use strict; | |
5 | use warnings; | |
d1348d38 | 6 | use JSON; |
a5d53377 | 7 | use Text::Tradition; |
d1348d38 | 8 | use Text::Tradition::Analysis qw/ group_variants /; |
a5d53377 | 9 | use Text::Tradition::Stemma; |
10 | ||
11 | binmode STDERR, ":utf8"; | |
12 | binmode STDOUT, ":utf8"; | |
13 | eval { no warnings; binmode $DB::OUT, ":utf8"; }; | |
14 | ||
a5d53377 | 15 | # Parse the tradition data |
7fd4b80c | 16 | my $informat = 'Self'; |
a5d53377 | 17 | |
7fd4b80c | 18 | my %args = ( 'input' => $informat, |
19 | 'file' => $ARGV[0] ); | |
e79c23c7 | 20 | my $tradition = Text::Tradition->new( %args ); |
a5d53377 | 21 | |
d1348d38 | 22 | # Parse the stemma data |
23 | my $stemma = Text::Tradition::Stemma->new( | |
24 | 'collation' => $tradition->collation, | |
25 | 'dot' => $ARGV[1], | |
26 | ); | |
a5d53377 | 27 | |
d1348d38 | 28 | my $wits = {}; |
29 | map { $wits->{$_} = 1 } $stemma->witnesses; | |
a5d53377 | 30 | |
d1348d38 | 31 | my $variant_groups = group_variants( $tradition->collation, $wits ); |
a5d53377 | 32 | |
d1348d38 | 33 | print encode_json( $variant_groups ); |