pub struct Document {
pub id: String,
pub text: String,
pub label: Vec<(usize, usize, String)>,
}
Expand description
An annotation is a text with a set of entities
This object is used to hold the text and the entities found in the text.
Fields§
§id: String
§text: String
§label: Vec<(usize, usize, String)>
Implementations§
source§impl Document
impl Document
sourcepub fn from_string(text: String) -> Self
pub fn from_string(text: String) -> Self
Create an annotation from a string
Examples
use quickner::models::Annotation;
let annotation = Annotation::from_string("Rust is developed by Mozilla".to_string());
assert_eq!(annotation.text, "Rust is developed by Mozilla");
pub fn new(text: String, label: Vec<(usize, usize, String)>) -> Self
sourcepub fn annotate(&mut self, entities: Vec<Entity>, case_sensitive: bool)
pub fn annotate(&mut self, entities: Vec<Entity>, case_sensitive: bool)
Annotate text given a set of entities
Examples
use quickner::models::Document;
use quickner::models::Entity;
use std::collections::HashSet;
let mut annotation = Annotation::from_string("Rust is developed by Mozilla".to_string());
let entities = vec![
Entity::new("Rust".to_string(), "Language".to_string()),
Entity::new("Mozilla".to_string(), "Organization".to_string()),
].into_iter().collect();
annotation.annotate(entities);
assert_eq!(annotation.label, vec![(0, 4, "Language".to_string()), (23, 30, "Organization".to_string())]);
Trait Implementations§
source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more