Skip to content

Commit

Permalink
rename annotation to quality_warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Uinelj committed Jan 24, 2023
1 parent 5368804 commit fa6f34f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pipelines/oscardoc/types/rebuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ lazy_static! {
"fields":[
{"name":"identification", "type":"identification"},
{"name":"harmful_pp", "type":["null", "float"]},
{"name":"annotation", "type":["null", {"type": "array", "items":"string"}]},
{"name":"quality_warnings", "type":["null", {"type": "array", "items":"string"}]},
{"name":"categories", "type":["null", {"type": "array", "items":"string"}]},
{"name": "sentence_identifications", "type":"array", "items":[
"null",
Expand Down
13 changes: 12 additions & 1 deletion src/transformers/annotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ impl<T> Default for Annotator<T> {

#[cfg(test)]
mod tests {
use std::collections::HashMap;

use oscar_io::v3::Metadata;

use crate::{pipelines::oscardoc::types::Document, transformers::Annotate};

use super::Annotator;
Expand All @@ -45,12 +49,19 @@ mod tests {
fn test_add() {
struct MockAnnotate {}
impl Annotate<Document> for MockAnnotate {
fn annotate(&self, _: &mut Document) {}
fn annotate(&self, doc: &mut Document) {
doc.metadata_mut().add_annotation("foo".to_string());
}
}

let mut a = Annotator::default();
a.add(Box::new(MockAnnotate {}));

assert_eq!(a.0.len(), 1);

let mut d = Document::new(String::new(), HashMap::new(), Metadata::default());
a.annotate(&mut d);

assert_eq!(d.metadata().annotation(), Some(&vec!["foo".to_string()]));
}
}

0 comments on commit fa6f34f

Please sign in to comment.