Skip to content

Commit

Permalink
Fix 'match in context' export for corpora without any coverage compon…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
matthias-stemmler committed Jul 20, 2024
1 parent 71eb7f6 commit 66812ff
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased] - (release date)

### Fixed

- "Match in context" columns are now produced correctly even for corpora without any coverage components.

## [1.1.0] - 2024-07-13

### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ The following types of columns are available:

Metadata of the corpus or document containing the match.

"Corpus" here refers to one of the items selected on the lower left. You can select the desired meta annotation from a dropdown. Special Annis-internal annotations are grouped under a separate "Annis" section at the bottom of the list, the others are specific to the selected corpora.
"Corpus" here refers to one of the items selected on the lower left. You can select the desired meta annotation from a dropdown. Annis standard annotations are grouped under a separate "Annis" section at the bottom of the list, the others are specific to the selected corpora.

3. **Match annotation**

An annotation of one of the nodes matched by the query.

You can select the annotation from a dropdown. Special Annis-internal annotations are grouped under a separate "Annis" section at the bottom of the list, the others are specific to the selected corpora. Note that this contains all available annotations of the selected corpora, even the ones that are also listed as meta annotations for "Corpus metadata" or "Document metadata" columns.
You can select the annotation from a dropdown. Annis standard annotations are grouped under a separate "Annis" section at the bottom of the list, the others are specific to the selected corpora. Note that this contains all available annotations of the selected corpora, even the ones that are also listed as meta annotations for "Corpus metadata" or "Document metadata" columns.

You also have to select for which node of the query the annotation should be exported, in case the query refers to multiple nodes.

Expand Down
6 changes: 5 additions & 1 deletion annimate_core/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,13 @@ impl<'a> GraphHelper<'a> {
source: NodeID,
target: NodeID,
) -> Result<bool, GraphAnnisCoreError> {
if source == target {
return Ok(true);
}

self.coverage_storages
.iter()
.map(|gs| gs.is_connected(source, target, 0, Bound::Included(1)))
.map(|gs| gs.is_connected(source, target, 1, Bound::Included(1)))
.fold_ok(false, |a, b| a || b)
}

Expand Down
3 changes: 3 additions & 0 deletions annimate_core/tests/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- `empty_graphml.zip`
- Name: empty
- Source: generated using graphANNIS, consists only of a corpus node
- `nocoverage.demo_graphml.zip`
- Name: nocoverage.demo
- Source: generated using graphANNIS, consists of text "There is no coverage." and has no coverage components
- `pcc2_v7_relANNIS.zip`
- Name: pcc2 (Potsdam Commentary Corpus 2)
- Source: <https://corpus-tools.org/corpora/pcc2_v7_relANNIS.zip>
Expand Down
Binary file added annimate_core/tests/data/nocoverage.demo_graphml.zip
Binary file not shown.
15 changes: 15 additions & 0 deletions annimate_core/tests/export_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,21 @@ export_matches_test! {
})),
],
}
nocoverage: {
corpus_paths: ["nocoverage.demo_graphml.zip"],
corpus_names: ["nocoverage.demo"],
aql_query: "tok=\"no\"",
query_language: AQL,
export_columns: [
Number,
Data(Text(TestExportDataText {
left_context: 2,
right_context: 2,
segmentation: None,
primary_node_indices: None,
})),
],
}
}

#[test]
Expand Down
20 changes: 20 additions & 0 deletions annimate_core/tests/snapshots/export_matches__nocoverage.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
source: annimate_core/tests/export_matches.rs
info:
corpus_paths:
- nocoverage.demo_graphml.zip
corpus_names:
- nocoverage.demo
aql_query: "tok=\"no\""
query_language: AQL
export_columns:
- Number
- Data:
Text:
left_context: 2
right_context: 2
segmentation: ~
primary_node_indices: ~
---
Number,Left context (tokens),Match (tokens),Right context (tokens)
1,There is,no,coverage .
2 changes: 1 addition & 1 deletion release.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"versionBump": "none"
"versionBump": "patch"
}

0 comments on commit 66812ff

Please sign in to comment.