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
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more