Skip to content

Commit

Permalink
documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Aug 12, 2020
1 parent 20c9941 commit 91d9b0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ if let Some(element) = doc.get_element_by_id("example.s.1.w.1") {
}
```

### Declarations

All annotation types need to be declared in FoLiA, but the library does that for you automatically as long as you don't
set ``DocumentProperties.autodeclare`` to ``false``. Explicit declarations are done using ``Document.declare()``. Here
is a simple set-less declaration:

```rust
doc.declare(folia::AnnotationType::SENTENCE, &None, &None, &None);
```

Here a more elaborate one:

```rust
doc.declare(folia::AnnotationType::POS, Some("https://somewhere/my/pos/set".to_string()), &None, &None);
```

### Provenance

FoLiA v2 comes with extensive provenance support, so this library implements that as well. You can associate an active
Expand All @@ -121,7 +137,8 @@ processor by setting it in ``folia::DocumentProperties``:
let doc = Document::new("example", DocumentProperties::default().with_processor(processor)).expect("document");
```

Switching processors on-the-fly can be done with ``doc.active_processor(processor_key)``.
Switching processors on-the-fly can be done with ``doc.active_processor(processor_key)``. Any declarations made after
activating a processor will automatically assign that processor.

## Benchmarks

Expand Down
3 changes: 2 additions & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Declaration {
}

impl Declaration {
///Creates a new declaration, which can for instance be passed to ``Document.add_declaration()``.
///Creates a new declaration, which can for instance be passed to ``Document.add_declaration()`` or the higher-lever ``Document.declare()``.
pub fn new(annotationtype: AnnotationType, set: Option<String>, alias: Option<String>, format: Option<String>) -> Declaration {
Declaration { annotationtype: annotationtype, set: set, alias: alias, processors: vec![] , format: format, classes: None, key: None, subclasses: None, subsets: None }
}
Expand Down Expand Up @@ -504,6 +504,7 @@ impl Processor {
}
self
}

///attempts to automatically fill the processor's fields based on the environment
pub fn autofill(self) -> Processor {
let host: String = env::var("HOST").unwrap_or_default();
Expand Down

0 comments on commit 91d9b0a

Please sign in to comment.