diff --git a/README.pod b/README.pod index 849142f..aea9b81 100644 --- a/README.pod +++ b/README.pod @@ -6,9 +6,32 @@ ud - TrEd extension to display and edit Universal Dependencies =head1 DESCRIPTION -Use mouse to change the tree structure. Drop a node with C to add or -remove an enhanced dependency. Press C to edit the current node's -C. +=over 2 + +=item * + +Dropping node C on node C attaches node C to node C. An enhanced +dependency is created together with the basic one, if an enhanced dependency +existed to the old or new parent, it is removed. + +=item * + +Dropping node C on node C while pressing C toggles existence of +an enhanced dependency of node C on node C. If a dependency was created, +the user is asked for its type. This works even when C already is C's +parent. + +=item * + +Dropping node C on node C while pressing C attaches node C to +node C without creating an enhanced dependency. If an enhanced dependency +existed to the old or new parent, it is removed. + +=item * + +Pressing C opens a dialog box to edit the current node's dependency type. +If previously an enhanced dependency of the same type as the basic dependency +existed, it is changed together with it, otherwise, it stays unchanged. =head1 INSTALLATION diff --git a/ud/contrib/ud/ud.inc b/ud/contrib/ud/ud.inc index 09b96a6..25d30bd 100644 --- a/ud/contrib/ud/ud.inc +++ b/ud/contrib/ud/ud.inc @@ -142,13 +142,16 @@ } else { return if $target == $parent; - my @deps = (_create_container( - $target->{ord}, $node->{deprel}), - grep $_->{func} ne $node->{deprel} - && $_->content != $parent->{ord}, + my $with_enhanced = ! (defined $mod && $mod eq 'Shift'); + my @deps = ($with_enhanced + ? _create_container($target->{ord}, + $node->{deprel}) + : (), + grep $_->content != $parent->{ord} + && $_->content != $target->{ord}, ListV($node->{deps})); delete $node->{deps}; - $node->{deps} = List(@deps); + $node->{deps} = List(@deps) if @deps; CutPaste($node, $target); ChangingFile(1); } diff --git a/ud/stylesheets/UD b/ud/stylesheets/UD index 951b792..7d145c8 100644 --- a/ud/stylesheets/UD +++ b/ud/stylesheets/UD @@ -6,32 +6,33 @@ node: ${id}${form}#{blue}${deprel} style: {deps}) { - my @deps = grep { - ($_->content // 0) ne ($this->parent->{ord} // 0) - } ListV($this->{deps}); - - my $is_parent_in_deps = grep $_->content == $this->parent->{ord} - && $_->{func} eq $this->{deprel}, - ListV($this->{deps}); - - my $coords = join '&', 'n,n,p,p', map { - my ($parent, $func) = ($_->content, $_->{func}); - my $expression = $parent ? "[ord=$parent]" : '[! $this->root !]'; - "n,n,(x$expression+xn)/2,(y$expression+yn)/2.5,x$expression,y$expression" - } @deps; - - my $arrows = join '&', 'none', ('last') x @deps; - my $colours = join '&', ($is_parent_in_deps ? 'grey' : 'cyan'), ('orange') x @deps; - my $widths = join '&', ($is_parent_in_deps ? '2' : '1'), ('1') x @deps; - my $smooth = join '&', '0', ('1') x @deps; - my $hints = join '&', "", map "$_->{func}", @deps; - my $deco = join '&', "", map "shape=text;font=SansSerif 9;fill=magenta;coords=n,n;start=20;text=$_->{func}", @deps; - - "#{Line-coords:$coords}#{Line-fill:$colours}#{Line-arrow:$arrows}" - . "#{Line-width:$widths}#{Line-smooth:$smooth}#{Line-hint:$hints}" - . "#{Line-decoration:$deco}" - . ('#{Oval-fill:whitesmoke}#{CurrentOval-fill:pink}#{Oval-outline:cyan}' x $this->{ord} =~ /\./); - } + my @deps = grep { + ($_->content // 0) ne ($this->parent->{ord} // 0) + } ListV($this->{deps}); + + my $is_parent_in_deps = grep $_->content == $this->parent->{ord} + && $_->{func} eq $this->{deprel}, + ListV($this->{deps}); + warn $this->{ord}, ' ', $is_parent_in_deps ? 'yes' : 'no'; + + my $coords = join '&', 'n,n,p,p', map { + my ($parent, $func) = ($_->content, $_->{func}); + my $expression = $parent ? "[ord=$parent]" : '[! $this->root !]'; + "n,n,(x$expression+xn)/2,(y$expression+yn)/2.5,x$expression,y$expression" + } @deps; + + my $arrows = join '&', 'none', ('last') x @deps; + my $colours = join '&', ($is_parent_in_deps ? 'grey' : 'cyan'), ('orange') x @deps; + my $widths = join '&', ($is_parent_in_deps ? '2' : '1'), ('1') x @deps; + my $smooth = join '&', '0', ('1') x @deps; + my $hints = join '&', "", map "$_->{func}", @deps; + my $deco = join '&', "", map "shape=text;font=SansSerif 9;fill=magenta;coords=n,n;start=20;text=$_->{func}", @deps; + + warn "\t$colours | $widths"; + + "#{Line-coords:$coords}#{Line-fill:$colours}#{Line-arrow:$arrows}" + . "#{Line-width:$widths}#{Line-smooth:$smooth}#{Line-hint:$hints}" + . "#{Line-decoration:$deco}" + . ('#{Oval-fill:whitesmoke}#{CurrentOval-fill:pink}#{Oval-outline:cyan}' x $this->{ord} =~ /\./); ?>