8 use Text::Tradition::Directory;
11 binmode STDOUT, ':utf8';
12 binmode STDERR, ':utf8';
13 eval { no warnings; binmode $DB::OUT, ':utf8'; $DB::deep = 1000 };
15 my( $dbuser, $dbpass );
16 my $dsn = 'dbi:SQLite:dbname=stemmaweb/db/traditions.db';
21 'u|user=s' => \$dbuser,
22 'p|pass=s' => \$dbpass,
23 'n|test' => \$testrun,
26 my $dbopts = { dsn => $dsn };
27 $dbopts->{extra_args}->{user} = $dbuser if $dbuser;
28 $dbopts->{extra_args}->{password} = $dbpass if $dbpass;
30 my $dir = Text::Tradition::Directory->new( $dbopts );
32 my $scope = $dir->new_scope();
33 my $lookfor = $ARGV[0] || '';
34 foreach my $tinfo ( $dir->traditionlist() ) {
35 next if $tinfo->{'name'} eq 'xxxxx';
36 next unless $tinfo->{'name'} =~ /$lookfor/ || $tinfo->{'id'} eq $lookfor;
37 my $tradition = $dir->lookup( $tinfo->{'id'} );
38 say "Looking at tradition " . $tradition->name;
39 my $c = $tradition->collation;
41 # Anywhere in the graph that there is a reading that joins only to a single
42 # successor, and neither of these have any relationships, just join the two
45 # Save/update the current path texts
46 foreach my $wit ( $tradition->witnesses ) {
47 my @pathtext = split( /\s+/, $c->path_text( $wit->sigil ) );
48 $wit->text( \@pathtext );
49 if( $wit->is_layered ) {
50 my @layertext = split( /\s+/, $c->path_text( $wit->sigil.$c->ac_label ) );
51 $wit->layertext( \@layertext );
56 $c->compress_readings();
58 $dir->save( $tradition );