Skip to content

Commit

Permalink
Provide default value for "id_column" in "table" exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskrause committed Aug 29, 2024
1 parent 63507ae commit 1071448
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
7 changes: 6 additions & 1 deletion src/exporter/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ pub struct ExportTable {
#[serde(default, deserialize_with = "deserialize_annotation_component_seq")]
outgoing: Vec<AnnotationComponent>,
/// If `true` (the default), always output a column with the ID of the node.
#[serde(default = "default_id_column")]
id_column: bool,
}

fn default_id_column() -> bool {
true
}

impl Default for ExportTable {
fn default() -> Self {
Self {
Expand All @@ -112,7 +117,7 @@ impl Default for ExportTable {
no_value: String::default(),
ingoing: vec![],
outgoing: vec![],
id_column: true,
id_column: default_id_column(),
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/manipulator/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use struct_field_names_as_array::FieldNamesAsSlice;
/// A `target` can also be a list. In this case, a new span is created that
/// covers the same token as the referenced nodes of the match.
/// ```toml
/// [[rules]]
/// [[rules]]
/// query = "tok=/more/ . tok"
/// target = [1,2]
/// ns = "mapper"
Expand All @@ -56,7 +56,7 @@ use struct_field_names_as_array::FieldNamesAsSlice;
/// Instead of a fixed value, you can also use an existing annotation value
/// from the matched nodes copy the value.
/// ```toml
/// [[rules]]
/// [[rules]]
/// query = "tok=\"complicated\""
/// target = 1
/// ns = ""
Expand All @@ -67,7 +67,7 @@ use struct_field_names_as_array::FieldNamesAsSlice;
/// It is also possible to replace all occurences in the original value that
/// match a `search` regular expression with a `replacement` value.
/// ```toml
/// [[rules]]
/// [[rules]]
/// query = "tok=\"complicated\""
/// target = 1
/// ns = ""
Expand All @@ -80,7 +80,7 @@ use struct_field_names_as_array::FieldNamesAsSlice;
/// expression (e.g. "${0}" for the whole match or "${1}" for the first match
/// group).
/// ```toml
/// [[rules]]
/// [[rules]]
/// query = "tok=\"New York\""
/// target = 1
/// ns = ""
Expand Down Expand Up @@ -449,10 +449,10 @@ mod tests {
g.apply_update(&mut updates, |_msg| {}).unwrap();

let config = r#"
[[rules]]
[[rules]]
query = "tok"
target = 1
ns = "test_ns"
ns = "test_ns"
name = "test"
value = {copy = 1}
"#;
Expand Down Expand Up @@ -533,10 +533,10 @@ mod tests {
#[test]
fn test_parse_complicated_replace() {
let config = r#"
[[rules]]
[[rules]]
query = "tok=\"New York\""
target = 1
ns = ""
ns = ""
name = "abbr"
[rules.value]
Expand All @@ -562,10 +562,10 @@ replacements = [["([A-Z])[a-z]+ ([A-Z])[a-z]+", "${1}${2}"]]
#[test]
fn test_ridges_clean_resolver() {
let config = r#"
[[rules]]
[[rules]]
query = "tok"
target = 1
ns = "test"
ns = "test"
name = "clean"
[rules.value]
Expand Down Expand Up @@ -613,7 +613,7 @@ replacements = [
g.apply_update(&mut updates, |_msg| {}).unwrap();

let config = r#"
[[rules]]
[[rules]]
query = "tok=/more/ . tok"
target = [1,2]
ns = "mapper"
Expand Down Expand Up @@ -659,26 +659,26 @@ value = "comparison"

fn main_test(on_disk: bool) -> Result<(), Box<dyn std::error::Error>> {
let config = r#"
[[rules]]
[[rules]]
query = "tok=/I/"
target = 1
ns = ""
name = "pos"
value = "PRON"
value = "PRON"
[[rules]]
query = "tok=/am/"
target = 1
ns = ""
name = "pos"
value = "VERB"
value = "VERB"
[[rules]]
query = "tok=/in/"
target = 1
ns = ""
name = "pos"
value = "ADP"
value = "ADP"
[[rules]]
query = "tok=/New York/"
Expand Down

0 comments on commit 1071448

Please sign in to comment.