package Text::Tradition::Parser::JSON;
use strict;
use warnings;
use JSON qw/ from_json /;
=head1 NAME
Text::Tradition::Parser::JSON
=head1 SYNOPSIS
use Text::Tradition;
my $tradition = Te
'name' => 'my text',
'input' => 'JSON',
'string' => $json_encoded_utf8,
);
=head1 DESCRIPTION
Parser module for Text::Tradition to read a JSON alignment table format such
as that pro
option_hash must contain either a 'file' or a
'string' argument with the JSON structure to be parsed.
The structure of the JSON is thus:
{ alignment => [ { witness => "SIGIL",
} @succ;
}
## Utility methods
sub _stringify {
my $self = shift;
return $self->id;
}
sub TO_JSON {
my $self = shift;
return $self->text;
}
sub throw {
Text::Tradition::Error->throw(
'iden
urceType',
as 'Str',
where { $_ =~ /^(xmldesc|plaintext|json|collation)$/ },
message { 'Source type must be one of xmldesc, plaintext, json, collation' };
subtype 'Sigil',
as 'Str',
where { $_
code_utf8 );
use File::Temp;
use File::Which;
use Graph;
use IPC::Run qw( run binary );
use JSON qw/ to_json /;
use Text::CSV;
use Text::Tradition::Collation::Data;
use Text::Tradition::Collation::Rea
);
}
}
}
=head2 as_adjacency_list
Returns a JSON structure that represents the collation sequence graph.
=begin testing
use JSON qw/ from_json /;
use Text::Tradition;
my $t = Text::Tradition-
tical' } );
# Create an adjacency list of the whole thing; test the output.
my $adj_whole = from_json( $c->as_adjacency_list() );
is( scalar @$adj_whole, scalar $c->readings(),
"Same number of node
package Text::Tradition::Witness;
use vars qw( %tags );
use JSON;
use Moose;
use Text::Tradition::Datatypes;
use Text::TEI::Markup qw( word_tag_wrap );
use TryCatch;
=head1 NAME
Text::Tradition::Wi
d.
=item * sourcetype - What sort of witness data this is. Options are
'xmldesc', 'plaintext', 'json', or 'collation' (the last should only be
used by Collation parsers.)
=item * file
=item * stri
e JSON witnesses via object
open( JSIN, 't/data/witnesses/testwit.json' ) or die "Could not open JSON test input";
binmode( JSIN, ':encoding(UTF-8)' );
my @lines = <JSIN>;
close JSIN;
$trad->add_json_
package Text::Tradition;
use JSON qw / from_json /;
use Module::Load;
use Moose;
use Moose::Util qw/ does_role apply_all_roles /;
use Safe::Isa;
use Text::Tradition::Collation;
use Text::Tradition::E
CollateX
=item * CTE - a TEI XML format produced by Classical Text Editor
=item * JSON - an alignment table in JSON format, as produced by CollateX and
other tools
=item * TEI - a TEI parallel seg
priate parser on the given data
my @format_standalone = qw/ Self CollateText CollateX CTE JSON TEI Tabular /;
my @format_basetext = qw/ KUL /;
my $use_base;
my $format