Skip to content

Adding root edges to dependency tree visualizer #920

Open

Description

@amir-zeldes

Currently, root edges are not visualized in the dependency tree visualizer, presumably because the data model can't represent edges with no source, so they are lost on import. I propose solving this in one of two ways (or even both, with vis config determining how to behave):

  1. Modify conllu import to introduce a non-terminal node as the source of root edges per sentence, then adjust the visualizer to display that edge
  2. Leave data model as-is, but introduce a configuration that makes the visualizer draw the vertical, incoming edge for token nodes that have no parent annotation (not just one with source outside of the context window - we would need to know that the token has no such edge anywhere in the graph)

I realize both of these are not trivial, but I think if dependency trees are a major datatype supported by the system, ANNIS should be able to visualize root edges as is standard in other platforms handling dependencies (plus maybe an AI agent could implement this without too much trouble?)

Activity

  1. MartinKl commented on Oct 30, 2026

    @MartinKl
    Contributor

    I feel option 2 is the better way to go, as I do not share the preference of having this edge visualized, as it technically does not exist. Identifying roots via the absence of an incoming edge visually gives a cleaner appearance in my eyes, but I completely understand that not everybody shares this preference.

    I have a question: Would you distinguish true root cases from non-attached nodes, e. g. the verbal root of a sentence vs. unattached punctuation? My impression is that not even all conllu files make that distinction anyway, but for exactly this reason one might end up with many root edges per sentence. This speaks in favor of implementing 2, but kind of 1 as well for cases were the distinction is made. I created korpling/annatto#573 for the latter.

  2. amir-zeldes commented on Oct 30, 2026

    @amir-zeldes
    CollaboratorAuthor

    Identifying roots via the absence of an incoming edge visually gives a cleaner appearance in my eyes, but I completely understand that not everybody shares this preference. ... Would you distinguish true root cases from non-attached nodes, e. g. the verbal root of a sentence vs. unattached punctuation?

    I understand these hesitations from a purely theoretical point of view - datasets could make a meaningful distinction between a reified root edge with no source, and absence of a root-like edge, or have multiple roots etc. But from a practical perspective, and this may be my own bias, I get the impression that >90% of the work using dependencies right now is specifically using UD (or let's also include SUD since it's the same in this case), and UD prohibits more than one root per sentence, as well as tokens with an unfilled parent field. So if ANNIS is meant to be a current corpus search tool serving people who work with dependency trees, it is definitely an outlier in not visualizing root edges. I teach UD and ANNIS in class every year, and students are always thrown by the lack of a root edge - it's what the annotation interfaces and other search tools like Grew Match lead them to expect.

    This speaks in favor of implementing 2, but kind of 1 as well for cases were the distinction is made

    Agreed, it would be nice to have both options, but what I think is really urgent if we want ANNIS to be popular and not become obsolete is some visualization for roots, even if we only get 2 and have this simplifying assumption that dependency trees always have exactly one root edge. It's just something that user expect, and probably covers a ~90% share of the market for dependency corpora (made up ballpark figure, I admit)

  3. amir-zeldes commented on Oct 30, 2026

    @amir-zeldes
    CollaboratorAuthor

    I created korpling/annatto#573 for the latter.

    Oh, thanks for that BTW! But it's only going to be useful if ANNIS can read the structure in the arch dep vis!

  4. MartinKl commented on Nov 8, 2026

    @MartinKl
    Contributor

    I dug a bit in the code and this appears to be quite simple: The js script the visualizer uses already has the required functionality. I attach a screenshot.

    Image

    The question now is how to "diagnose" root nodes. I propose we add a visualizer mapping that lets the user choose between:

    • no root edges (for people like me)
    • root-style edges in the visualization for any edge incoming from "outside" (that is from a node that is not part of the ordering, in Annatto's output model there will be an edge from the sentence span to the root node, as an example). I'd call this mode "explicit".
    • potential future option: root-style edges for edges incoming from the outside and unattached nodes. I'd refer to that as "implicit". This could be tricky, though, as that could make any token, whose governing token is outside of the match window, a root node. Therefore, I suggest we keep this option in mind, but do not implement it for now.

    So the proposed implementation only requires a binary mapping and could go for a boolean mapping key display_root_edges (or sth along those lines).

    One remaining question is if the incoming root edge's label should be evaluated, or if the edge's mere existence qualifies it for being labeled "root". A practical and somehow intermediate option would be to say that empty or missing labels on root edges are overwritten with "root". An unlabeled edge does not really seem desirable, as it's somehow ambiguous (it could be misunderstood as "this token's governing token is outside the match window").

  5. MartinKl commented on Nov 8, 2026

    @MartinKl
    Contributor

    A short addition: This adds the requirement that terminal nodes are explicitly ordered to allow to display a root edge. I think that's not too unreasonable.

    An alternative approach, btw., would be to say an edge, no matter where it comes from, that is labeled "root" will be displayed as root edge. But I consider that less favorable, as this restricts the vocabulary of label sets. Diagnosing from strings rather than structural features feels "unpleasant" as well.

  6. MartinKl commented on Nov 8, 2026

    @MartinKl
    Contributor

    Having had some further discussions with myself I think its actually best (given the original purpose of the post/request) to let the user define which edge label should be interpreted as root label. That only constrains label sets to the extent that roots have to be highlighted with a unique label, which Dependency schemes usually provide (none comes to mind that doesn't). This way the implementation is most lightweight, covers all common use cases, plus there is no need to ensure the existence of ordering edges (there are cases where the tokens are actually spans and might just inherit there ordering from subtokens). The only thing left to the user is to ensure the existence of the edge. This can be achieved by using the sentence span as source node as outlined above.

    If at any point in the future this is not sufficient, we can still extend the functionality.

  7. MartinKl commented on Nov 10, 2026

    @MartinKl
    Contributor

    There is pull request #921 which implements mapping certain edge labels as roots. This is the least complex in terms of configuration of the visualizer and code base.

    For corpora, that currently do not have the incoming root edge there is a way of patching the corpus directly on the database entry using Annatto. Here an example for GUM (and GUM only) which I tested:

    [load]
    database = "$PATH_TO_V4"
    corpus = "GUM"
    
    [[graph_op]]
    action = "check"
    
    [[graph_op.config.tests]]
    query = 'node ->dep[func="root"] tok_func=/root/'
    expected = 0
    description = "Make sure the corpus is unpatched / Forbid repeated execution."
    
    [[graph_op]]
    action = "map"
    
    [[graph_op.config.mapping.rules]]
    query = 'tok_func="root" _ident_ annis:node_name'
    target = [1]
    anno = "patch::deproot"
    value = { copy = 2 }
    
    [[graph_op]]
    action = "link"
    
    [graph_op.config]
    source_query = "patch:deproot"
    source_node = 1
    source_value = [1]
    target_query = "annis:node_name _=_ gum:tok_func=/root/"
    target_node = 1
    target_value = [1]
    target_to_edge = [2]
    component = { ctype = "Pointing", layer = "dep", name = "dep" }
    
    [[graph_op]]  # clean up
    action = "revise"
    
    [[graph_op.config.node_annos]]
    from = "patch::deproot"
    
    [[graph_op.config.edge_annos]]
    from = "gum::tok_func"
    to = "dep::func"
    
    [save]
    target = "$PATH_TO_V4"
    
    
    Image
  8. linked a pull request that will close this issueFeature/arch dependency visualize root edge #921on Nov 10, 2026
  9. amir-zeldes commented on Nov 10, 2026

    @amir-zeldes
    CollaboratorAuthor

    That's neat! TBH GUM's build bot still has Pepper integrated into it (I love how jars just keep working for years and years), so the Annatto part won't work for that immediately, but we do store the deprel as a token annotation (tok_func in GUM), so if there was a resolver setting for triggering this behavior based on a token annotation, that would work as well!

  10. MartinKl commented on Nov 11, 2026

    @MartinKl
    Contributor

    I added that option. When root_label is set to a value, setting root_label_node_key (the complex name is supposed to make people aware of the dependency of the two settings) to an annotation key (in your case "gum::tok_func") will make the visualizer look for the root marker on a node, not an edge.

  11. amir-zeldes commented on Nov 11, 2026

    @amir-zeldes
    CollaboratorAuthor

    Excellent! Can you say what the syntax is for the legacy relANNIS resolver_vis_map table mappings field?

  12. MartinKl commented on Nov 12, 2026

    @MartinKl
    Contributor

    if I am not mistaken, it should be

    GUM	NULL	dep	edge	arch_dependency	dependencies (UD)	hidden	3	root_label:root;root_label_node_key:gum::tok_func
    
  13. amir-zeldes commented on Nov 13, 2026

    @amir-zeldes
    CollaboratorAuthor

    OK, happy to test this as soon as a new front-end release is minted! We have the latest ANNIS4 running now, so I hope to be able to give more frequent feedback as users report issues. BTW right now I'm experiences occasional full server OS crashes on importing a corpus to the backend - has anyone encountered that? I can open an issue for it, but I'm not 100% sure what's causing it / whether it's an issue with my server setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions