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