You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adding root edges to dependency tree visualizer #920
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):
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
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?)
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.
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)
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.
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").
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.
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.
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:
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!
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.
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.
Activity
MartinKl commentedon Oct 30, 2026
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.
amir-zeldes commentedon Oct 30, 2026
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.
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)
amir-zeldes commentedon Oct 30, 2026
Oh, thanks for that BTW! But it's only going to be useful if ANNIS can read the structure in the arch dep vis!
MartinKl commentedon Nov 8, 2026
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.
The question now is how to "diagnose" root nodes. I propose we add a visualizer mapping that lets the user choose between:
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").
MartinKl commentedon Nov 8, 2026
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.
MartinKl commentedon Nov 8, 2026
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.
MartinKl commentedon Nov 10, 2026
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:
amir-zeldes commentedon Nov 10, 2026
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_funcin GUM), so if there was a resolver setting for triggering this behavior based on a token annotation, that would work as well!add option to identify roots via target node labels #920
MartinKl commentedon Nov 11, 2026
I added that option. When
root_labelis set to a value, settingroot_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.amir-zeldes commentedon Nov 11, 2026
Excellent! Can you say what the syntax is for the legacy relANNIS resolver_vis_map table mappings field?
MartinKl commentedon Nov 12, 2026
if I am not mistaken, it should be
amir-zeldes commentedon Nov 13, 2026
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.