Skip to content

Commit 870cda0

Browse files
authored
Merge pull request #495 from korpling/feature/raw-updates
Feature/raw updates
2 parents db671dc + 8fa57d7 commit 870cda0

File tree

14 files changed

+991
-6
lines changed

14 files changed

+991
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- better documentation for `revise`
1111
- Add `diff`, a graph op that highlights editions between subgraphs with specific edge and node annotations
12+
- Add `edit` for directly manipulating the graph via graph updates
1213

1314
### Changed
1415

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ facet = "0.28.0"
2525
facet-reflect = "0.28.0"
2626
git2 = { version = "0.20.2", default-features = false }
2727
glob = "0.3"
28-
graphannis = "4.0.0"
29-
graphannis-core = "4.0.0"
28+
graphannis = { git = 'https://github.com/korpling/graphannis.git' }
29+
graphannis-core = { git = 'https://github.com/korpling/graphannis.git' }
3030
graphviz-rust = "0.9.0"
3131
indicatif = "0.17"
3232
itertools = "0.12"
@@ -57,6 +57,7 @@ tempfile = "3"
5757
termimad = "0.30"
5858
text-splitter = "0.6.3"
5959
thiserror = "1.0"
60+
time = "0.3.44"
6061
tokenizations = "0.4.2"
6162
toml = "0.8.0"
6263
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
33
| Import formats | [conllu](importers/conllu.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) |
44
| 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) |
5-
| Graph operations | [align](graph_ops/align.md), [check](graph_ops/check.md), [collapse](graph_ops/collapse.md), [diff](graph_ops/diff.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), [revise](graph_ops/revise.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) |
5+
| Graph operations | [align](graph_ops/align.md), [check](graph_ops/check.md), [collapse](graph_ops/collapse.md), [diff](graph_ops/diff.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), [revise](graph_ops/revise.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) |

docs/graph_ops/edit.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# edit (graph_operation)
2+
3+
Use this to directly edit the graph via graph update instructions.
4+
5+
The following builds a graph and then reverts all steps back to the
6+
empty graph:
7+
8+
```toml
9+
[[graph_op]]
10+
action = "edit"
11+
12+
[[graph_op.config.instructions]] # note that you can define more than one node to be added for the same type
13+
do = "add"
14+
nodes = ["a", "b"]
15+
node_type = "corpus"
16+
17+
[[graph_op.config.instructions]] # note that theorectically you can define more than one node to be targeted by the annotation
18+
do = "add"
19+
nodes = ["a"]
20+
anno = "annis::doc"
21+
value = "a"
22+
23+
[[graph_op.config.instructions]]
24+
do = "add"
25+
nodes = ["b"]
26+
anno = "annis::doc"
27+
value = "b"
28+
29+
[[graph_op.config.instructions]]
30+
do = "add"
31+
nodes = ["a#t1", "a#t2", "b#t1", "b#t2"]
32+
33+
[[graph_op.config.instructions]] # Note that you can define more than one edge for a single instruction, as long as the component is the same
34+
do = "add"
35+
edges = [
36+
{ source = "a#t1", target = "a"},
37+
{ source = "a#t2", target = "a"},
38+
{ source = "b#t1", target = "b"},
39+
{ source = "b#t2", target = "b"}
40+
]
41+
component = { ctype = "PartOf", layer = "annis", name = "" }
42+
43+
[[graph_op.config.instructions]]
44+
do = "add"
45+
edges = [{ source = "a#t2", target = "a#t1"}]
46+
component = { ctype = "Pointing", layer = "", name = "dep" }
47+
48+
[[graph_op.config.instructions]] # edge annotations also can target more than one edge
49+
do = "add"
50+
edges = [{ source = "a#t2", target = "a#t1"}]
51+
component = { ctype = "Pointing", layer = "", name = "dep" }
52+
anno = "default_ns::deprel"
53+
value = "subj"
54+
55+
### now revert
56+
57+
[[graph_op.config.instructions]]
58+
do = "rm"
59+
edges = [{ source = "a#t2", target = "a#t1"}]
60+
component = { ctype = "Pointing", layer = "", name = "dep" }
61+
annos = ["default_ns::deprel"]
62+
63+
[[graph_op.config.instructions]]
64+
do = "rm"
65+
edges = [{ source = "a#t2", target = "a#t1"}]
66+
component = { ctype = "Pointing", layer = "", name = "dep" }
67+
68+
[[graph_op.config.instructions]]
69+
do = "rm"
70+
edges = [
71+
{ source = "a#t1", target = "a"},
72+
{ source = "a#t2", target = "a"},
73+
{ source = "b#t1", target = "b"},
74+
{ source = "b#t2", target = "b"}
75+
]
76+
component = { ctype = "PartOf", layer = "annis", name = "" }
77+
78+
[[graph_op.config.instructions]]
79+
do = "rm"
80+
nodes = ["a#t1", "a#t2", "b#t1", "b#t2"]
81+
82+
[[graph_op.config.instructions]]
83+
do = "rm"
84+
nodes = ["a", "b"]
85+
annos = ["annis::doc"]
86+
87+
[[graph_op.config.instructions]]
88+
do = "rm"
89+
nodes = ["a", "b"]
90+
```
91+
92+
## Configuration
93+
94+
### instructions
95+
96+
Provide a set of instructions.
97+

src/estarde/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub(crate) mod anno_key;
22
pub(crate) mod annotation_component;
3+
pub(crate) mod update_event;
34

45
pub trait IntoInner {
56
type I;

0 commit comments

Comments
 (0)