make lacuna nodes lacunae from the beginning
[scpubgit/stemmatology.git] / lib / Text / Tradition / Parser / Tabular.pm
index 4c1e511..46fcbea 100644 (file)
@@ -146,29 +146,13 @@ sub parse {
         my $last_rdg = shift @$p;
         my $new_p = [ $last_rdg ];
         foreach my $rdg ( @$p ) {
-               $DB::single = 1 if $rdg->id eq '228,1';
-            if( $rdg->text eq '#LACUNA#' ) {
+            if( $rdg->is_lacuna && $last_rdg->is_lacuna ) {
                 # If we are in a lacuna already, drop this node.
-                # Otherwise make a lacuna node and drop this node.
-                unless( $last_rdg->is_lacuna ) {
-                       my $l_id = 'l' . $rdg->id;
-                       my $l;
-                       if( $c->has_reading( $l_id ) ) {
-                               $l = $c->reading( $l_id );
-                       } else {
-                       $l = $c->add_reading( {
-                                                       'collation' => $c,
-                                                       'id' => $l_id,
-                                                       'is_lacuna' => 1,
-                                                       } );
-                                       }
-                    push( @$new_p, $l );
-                    $last_rdg = $l;
-                }
-                $c->del_reading( $rdg );
+                               $c->del_reading( $rdg );
             } else {
-                # No lacuna, save the reading.
+                # Save the reading, lacuna or no.
                 push( @$new_p, $rdg );
+                $last_rdg = $rdg;
             }
         }
         push( @$new_p, $c->end );
@@ -198,11 +182,11 @@ sub make_nodes {
     my $ctr = 1;
     foreach my $w ( keys %unique ) {
        my $rargs = {
-               'collation' => $collation,
                'id' => "$index,$ctr",
                'rank' => $index,
                'text' => $w,
                };
+       $rargs->{'is_lacuna'} = 1 if $w eq '#LACUNA#';
         my $r = $collation->add_reading( $rargs );
         $unique{$w} = $r;
         $ctr++;