Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add export `ptb`.

### Fixed

- Documentation now properly names Toolbox import `toolbox`.

## [0.61.0] - 2026-10-16

### Added
Expand Down
10 changes: 5 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
| Type | Modules |
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Import formats | [conllu](importers/conllu.md), [elan](importers/elan.md), [exmaralda](importers/exmaralda.md), [git](importers/git.md), [graphml](importers/graphml.md), [meta](importers/meta.md), [none](importers/none.md), [opus](importers/opus.md), [path](importers/path.md), [ptb](importers/ptb.md), [relannis](importers/relannis.md), [saltxml](importers/saltxml.md), [table](importers/table.md), [text](importers/text.md), [textgrid](importers/textgrid.md), [bytealignedtoolbox](importers/bytealignedtoolbox.md), [treetagger](importers/treetagger.md), [webanno](importers/webanno.md), [whisper](importers/whisper.md), [xlsx](importers/xlsx.md), [xml](importers/xml.md) |
| Export formats | [conllu](exporters/conllu.md), [exmaralda](exporters/exmaralda.md), [graphml](exporters/graphml.md), [meta](exporters/meta.md), [saltxml](exporters/saltxml.md), [sequence](exporters/sequence.md), [table](exporters/table.md), [textgrid](exporters/textgrid.md), [treetagger](exporters/treetagger.md), [xlsx](exporters/xlsx.md) |
| Graph operations | [align](graph_ops/align.md), [check](graph_ops/check.md), [collapse](graph_ops/collapse.md), [unstable:diff](graph_ops/diff.md), [divide](graph_ops/divide.md), [edit](graph_ops/edit.md), [filter](graph_ops/filter.md), [visualize](graph_ops/visualize.md), [enumerate](graph_ops/enumerate.md), [link](graph_ops/link.md), [map](graph_ops/map.md), [move](graph_ops/move.md), [revise](graph_ops/revise.md), [span](graph_ops/span.md), [time](graph_ops/time.md), [chunk](graph_ops/chunk.md), [split](graph_ops/split.md), [sleep](graph_ops/sleep.md), [none](graph_ops/none.md) |
| Type | Modules |
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Import formats | [conllu](importers/conllu.md), [elan](importers/elan.md), [exmaralda](importers/exmaralda.md), [git](importers/git.md), [graphml](importers/graphml.md), [meta](importers/meta.md), [none](importers/none.md), [opus](importers/opus.md), [path](importers/path.md), [ptb](importers/ptb.md), [relannis](importers/relannis.md), [saltxml](importers/saltxml.md), [table](importers/table.md), [text](importers/text.md), [textgrid](importers/textgrid.md), [toolbox](importers/toolbox.md), [treetagger](importers/treetagger.md), [webanno](importers/webanno.md), [whisper](importers/whisper.md), [xlsx](importers/xlsx.md), [xml](importers/xml.md) |
| Export formats | [conllu](exporters/conllu.md), [exmaralda](exporters/exmaralda.md), [graphml](exporters/graphml.md), [meta](exporters/meta.md), [ptb](exporters/ptb.md), [saltxml](exporters/saltxml.md), [sequence](exporters/sequence.md), [table](exporters/table.md), [textgrid](exporters/textgrid.md), [treetagger](exporters/treetagger.md), [xlsx](exporters/xlsx.md) |
| Graph operations | [align](graph_ops/align.md), [check](graph_ops/check.md), [collapse](graph_ops/collapse.md), [unstable:diff](graph_ops/diff.md), [divide](graph_ops/divide.md), [edit](graph_ops/edit.md), [filter](graph_ops/filter.md), [visualize](graph_ops/visualize.md), [enumerate](graph_ops/enumerate.md), [link](graph_ops/link.md), [map](graph_ops/map.md), [move](graph_ops/move.md), [revise](graph_ops/revise.md), [span](graph_ops/span.md), [time](graph_ops/time.md), [chunk](graph_ops/chunk.md), [split](graph_ops/split.md), [sleep](graph_ops/sleep.md), [none](graph_ops/none.md) |
34 changes: 34 additions & 0 deletions docs/exporters/ptb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ptb (exporter)

This module exports tree structures in parentheses format as known from Penn Treebank.

## Configuration

### component

This is used to set the syntax component. The default is `{ ctype = "Dominance", layer = "syntax", name = ""}`.

### file_component

This component is used to split the corpus graph in separate files. Default is `{ ctype = "PartOf", layer = "annis", name = ""}`.

### file_key

The given key identifies the nodes gathering all nodes of a document. Default is `annis::doc`.

### nonterminal_key

This annotation key is used to derive the category of nonterminal nodes. Default is `syntax::cat`.

### terminal_key

This annotation key is used to derive the category of terminal nodes. Default is `syntax::pos`.

### text_key

This annotation key contains the text value of the leaves of the tree. Default is `annis::tok`.

### terminal_component

This component, usually an ordering, is used to identify the linear sequence of leave nodes. Default is `{ ctype = "Ordering", layer = "annis", name = ""}`.

11 changes: 8 additions & 3 deletions docs/importers/toolbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ Import annotations provided in the fieldlinguist's toolbox text format.

## Configuration

### target
### globals

This attribute sets the annotation layer, that other annotations will point to.
This needs to be set to avoid an invalid model.
The annotation names are considered global spans, i. e., they will cover all following
annotations' tokens until a follow-up value is defined. Also, they are considered single-valued
per line.

### span

Expand All @@ -16,6 +17,10 @@ are not considered delimiters, but part of the annotation value. Such annotation
rely on the existence of the target nodes, i. e. annotation lines without any other
non-spanning annotation in the block will be dropped.

### ignore

Lists the annotation markers to be ignored.

### explicit_null

Null values are represented as `-` in toolbox. If you want those to remain explicit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
source: src/importer/toolbox/tests.rs
expression: "toml::to_string(&importer_step).unwrap()"
---
format = "toolbox"
path = "./"
extensions = ["txt"]

[config]
globals = ["id"]
span = ["clause", "sentence"]
ignore = ["comment"]
explicit_null = false

[model]
default_ns = ""

[model.default_components.ordering]
ctype = "Ordering"
layer = "annis"
name = ""

[model.default_components.coverage]
ctype = "Coverage"
layer = "annis"
name = ""

[model.default_components.part_of]
ctype = "PartOf"
layer = "annis"
name = ""

[model.default_components.dominance]
ctype = "Dominance"
layer = "annis"
name = ""

[model.default_components.pointing]
ctype = "Pointing"
layer = ""
name = "point"
31 changes: 27 additions & 4 deletions src/importer/toolbox/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ use std::{fs, path::Path};
use graphannis::model::{AnnotationComponent, AnnotationComponentType};
use insta::assert_snapshot;

use crate::importer::{
DefaultComponents, DefaultImportConfiguration, GLOBAL_DEFAULT_DOMINANCE,
GLOBAL_DEFAULT_POINTING, GenericImportConfiguration, ModelConfiguration,
toolbox::ImportFLToolbox,
use crate::{
ImporterStep,
importer::{
DefaultComponents, DefaultImportConfiguration, GLOBAL_DEFAULT_DOMINANCE,
GLOBAL_DEFAULT_POINTING, GenericImportConfiguration, ModelConfiguration,
toolbox::ImportFLToolbox,
},
};

#[test]
Expand All @@ -28,6 +31,26 @@ fn serialize_custom() {
assert_snapshot!(serialization.unwrap());
}

#[test]
fn serialize_in_container() {
let module = crate::ReadFrom::Toolbox(ImportFLToolbox {
span: ["sentence".to_string(), "clause".to_string()]
.into_iter()
.collect(),
ignore: ["comment".to_string()].into_iter().collect(),
globals: ["id".to_string()].into_iter().collect(),
explicit_null: false,
});
let generic_config = module.reader().default_configuration();
let importer_step = ImporterStep {
module,
path: Path::new("./").to_path_buf(),
description: None,
generic_config,
};
assert_snapshot!(toml::to_string(&importer_step).unwrap());
}

#[test]
fn core_functionality() {
let ts = fs::read_to_string("tests/data/import/toolbox/build.toml");
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ pub enum ReadFrom {
Table(#[serde(default)] ImportTable),
Text(#[serde(default)] ImportText),
TextGrid(#[serde(default)] ImportTextgrid),
#[serde(rename = "toolbox")]
ByteAlignedToolBox(ImportFLToolbox),
Toolbox(ImportFLToolbox),
TreeTagger(#[serde(default)] ImportTreeTagger),
Webanno(#[serde(default)] ImportWebAnnoTSV),
Whisper(#[serde(default)] ImportWhisper),
Expand Down Expand Up @@ -166,7 +165,7 @@ impl ReadFrom {
ReadFrom::Xml(m) => m,
ReadFrom::Webanno(m) => m,
ReadFrom::Git(m) => m,
ReadFrom::ByteAlignedToolBox(m) => m,
ReadFrom::Toolbox(m) => m,
ReadFrom::Elan(m) => m,
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/snapshots/cli__list_modules.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
source: tests/cli.rs
expression: output
---
| Type | Modules |
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Import formats | conllu, elan, exmaralda, git, graphml, meta, none, opus, path, ptb, relannis, saltxml, table, text, textgrid, bytealignedtoolbox, treetagger, webanno, whisper, xlsx, xml |
| Export formats | conllu, exmaralda, graphml, meta, ptb, saltxml, sequence, table, textgrid, treetagger, xlsx |
| Graph operations | align, check, collapse, unstable:diff, divide, edit, filter, visualize, enumerate, link, map, move, revise, span, time, chunk, split, sleep, none |
| Type | Modules |
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Import formats | conllu, elan, exmaralda, git, graphml, meta, none, opus, path, ptb, relannis, saltxml, table, text, textgrid, toolbox, treetagger, webanno, whisper, xlsx, xml |
| Export formats | conllu, exmaralda, graphml, meta, ptb, saltxml, sequence, table, textgrid, treetagger, xlsx |
| Graph operations | align, check, collapse, unstable:diff, divide, edit, filter, visualize, enumerate, link, map, move, revise, span, time, chunk, split, sleep, none |

Use `annatto info <name>` to get more information about one of the formats or graph operations.
Loading