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
Linking tokens and metadata with the same namespace #767
In the corpus I am working with we have 2 participants in a signed dialogue, and they each have multiple annotation tiers. We use namespaces in the annotations e.g.
There are several answers or possible solutions to this problem caused by the different data models involved when creating the corpus and the limitations/capabilities of these data models. Like you did with the ->ident pointing relations, you need some way of connecting the annotation nodes to the speaker metadata. I don't think it is possible with the pure relANNIS data model (which is used when converting to ANNIS with Pepper), but there might be a way of leveraging the flexibility of the graphANNIS data model with some smaller scripting.
In the graphANNIS data model, this could be achieved by adding the meta annotations to corpus/objects for each speaker and then adding PartOf relations to the specific annotation nodes. There could e.g. be three subcorpus nodes and annotation nodes are either connected to the speaker corpus nodes or if they are more generic like the timeline tokens they could be attached directly to the document subcorpus node.
You could then search something like Gloss=/KANN.*/ @* AltersGruppe="31-45" and only the words that are part of a speaker sub-document that actually have this metadata would be found.
Because a token/annotation node can be part of several sub-corpora and annotations can exist between any node regardless of its PartOf relations, this would still allow grouping them into documents and display them together in the result view.
The obvious problem with this approach is, that no converters exists for directly converting data to the graphANNIS data model (e.g. in the GraphAML format that can be read by the import CLI. In theory, it would be possible to use the Python API to construct such corpora on your own, but this would be a lot of work.
By using Pepper to convert the data to relANNIS, two data models are involved: Salt and the relANNIS model.
The latter one is more restrictive, so I would focus on how to achieve something like you want in this data model (in theory one could write a GraphML exporter for Pepper, so one would only be limited by the Salt data model, but such an exporter does not exist yet).
RelANNIS has the concept of documents and texts. A document can consist of several texts, and it is possible to have pointing relations between annotation nodes of any text inside the same document. That could help in your case, but I assume you have some kind of timeline and thus means the relANNIS exporter will create a single text with empty token for the timeline items. Also, in relANNIS only documents can have metadata, not texts. This means you can't use the same structure as outlined for graphANNIS above.
I thought that it might be possible to solve this by adding node annotation labels with the speaker id and than do an "identical value" (==) operator search, but you still only have one document node for several speakers and thus you can't link the annotation to the distinct sub-corpus node belonging only to this speaker.
There might be a solution that makes use of the graphANNIS data model, but does not need the implementation of a full conversion script in Python. Instead, you might convert and import the corpus with Pepper and the graphANNIS CLI. Then, you could use the Python API to add some additional annotations and nodes as a post-processing step.
For every speaker you know (probably defined by the namespace of the document node annotations), you create a new graphANNIS node with the node type "speaker". It is important that this node type is neither "node" (an annotation node) nor "corpus" (a document). If this would be "corpus", it would be treated by the ANNIS frontend as document, and it won't be able to handle that there are several documents for an annotation node. Add all relevant metadata like age group to the speaker node. Then find all annotation nodes/Gloss/token that belong to that speaker and add a PartOf relation between the annotation node an the speaker node. It is totally OK for an annotation node to have multiple incoming PartOf edges.
If you want to distribute the post-processed corpus, you can export the modified corpus as GraphML using the graphANNIS command line. Or you just use a script that imports the corpus to a temporary data folder, post-processes it and then exports the result as GraphML.
I know that it might be frustrating to not have a simple way of solving this with relANNIS and the Pepper ecosystem. We have some ideas of a graphANNIS based Pepper to avoid the limitations of the Salt and relANNIS data model, but this is more experimental and not an actual project with estimated deadlines.
Activity
thomaskrause commentedon Jun 1, 2022
There are several answers or possible solutions to this problem caused by the different data models involved when creating the corpus and the limitations/capabilities of these data models. Like you did with the
->identpointing relations, you need some way of connecting the annotation nodes to the speaker metadata. I don't think it is possible with the pure relANNIS data model (which is used when converting to ANNIS with Pepper), but there might be a way of leveraging the flexibility of the graphANNIS data model with some smaller scripting.In the graphANNIS data model, this could be achieved by adding the meta annotations to corpus/objects for each speaker and then adding
PartOfrelations to the specific annotation nodes. There could e.g. be three subcorpus nodes and annotation nodes are either connected to the speaker corpus nodes or if they are more generic like the timeline tokens they could be attached directly to the document subcorpus node.You could then search something like
Gloss=/KANN.*/ @* AltersGruppe="31-45"and only the words that are part of a speaker sub-document that actually have this metadata would be found.Because a token/annotation node can be part of several sub-corpora and annotations can exist between any node regardless of its
PartOfrelations, this would still allow grouping them into documents and display them together in the result view.The obvious problem with this approach is, that no converters exists for directly converting data to the graphANNIS data model (e.g. in the GraphAML format that can be read by the import CLI. In theory, it would be possible to use the Python API to construct such corpora on your own, but this would be a lot of work.
By using Pepper to convert the data to relANNIS, two data models are involved: Salt and the relANNIS model.
The latter one is more restrictive, so I would focus on how to achieve something like you want in this data model (in theory one could write a GraphML exporter for Pepper, so one would only be limited by the Salt data model, but such an exporter does not exist yet).
RelANNIS has the concept of documents and texts. A document can consist of several texts, and it is possible to have pointing relations between annotation nodes of any text inside the same document. That could help in your case, but I assume you have some kind of timeline and thus means the relANNIS exporter will create a single text with empty token for the timeline items. Also, in relANNIS only documents can have metadata, not texts. This means you can't use the same structure as outlined for graphANNIS above.
I thought that it might be possible to solve this by adding node annotation labels with the speaker id and than do an "identical value" (
==) operator search, but you still only have one document node for several speakers and thus you can't link the annotation to the distinct sub-corpus node belonging only to this speaker.There might be a solution that makes use of the graphANNIS data model, but does not need the implementation of a full conversion script in Python. Instead, you might convert and import the corpus with Pepper and the graphANNIS CLI. Then, you could use the Python API to add some additional annotations and nodes as a post-processing step.
For every speaker you know (probably defined by the namespace of the document node annotations), you create a new graphANNIS node with the node type "speaker". It is important that this node type is neither "node" (an annotation node) nor "corpus" (a document). If this would be "corpus", it would be treated by the ANNIS frontend as document, and it won't be able to handle that there are several documents for an annotation node. Add all relevant metadata like age group to the speaker node. Then find all annotation nodes/Gloss/token that belong to that speaker and add a
PartOfrelation between the annotation node an the speaker node. It is totally OK for an annotation node to have multiple incomingPartOfedges.This would allow you to search for
and
If you want to distribute the post-processed corpus, you can export the modified corpus as GraphML using the graphANNIS command line. Or you just use a script that imports the corpus to a temporary data folder, post-processes it and then exports the result as GraphML.
I know that it might be frustrating to not have a simple way of solving this with relANNIS and the Pepper ecosystem. We have some ideas of a graphANNIS based Pepper to avoid the limitations of the Salt and relANNIS data model, but this is more experimental and not an actual project with estimated deadlines.