pub struct Quickner {
pub config: Config,
pub config_file: Option<String>,
pub documents: Vec<Document>,
pub entities: Vec<Entity>,
pub documents_hash: HashMap<String, Document>,
pub documents_label_index: HashMap<String, Vec<String>>,
pub documents_entities_index: HashMap<String, Vec<String>>,
}
Expand description
Quickner is the main struct of the application It holds the configuration file and the path to the configuration file
Fields§
§config: Config
Path to the configuration file Default: ./config.toml
config_file: Option<String>
§documents: Vec<Document>
§entities: Vec<Entity>
§documents_hash: HashMap<String, Document>
§documents_label_index: HashMap<String, Vec<String>>
§documents_entities_index: HashMap<String, Vec<String>>
Implementations§
Source§impl Quickner
impl Quickner
Sourcepub fn annotate(&mut self)
pub fn annotate(&mut self)
Annotate the texts with the entities
§Example
let mut annotations = Annotations::new(entities, texts);
annotations.annotate();
§Panics
This function will panic if the texts are not loaded
§Performance
This function is parallelized using rayon
§Progress
This function will show a progress bar
§Arguments
self
- The annotations
§Returns
self
- The annotations with the annotations added
§Errors
This function will return an error if the texts are not loaded
Sourcepub fn new(config_file: Option<&str>) -> Self
pub fn new(config_file: Option<&str>) -> Self
Creates a new instance of Quickner If no configuration file is provided, the default configuration file is used. Default: ./config.toml
§Arguments
config_file
- The path to the configuration file
§Example
use quickner::Quickner;
let quickner = Quickner::new(Some("./config.toml"));
§Panics
This function will panic if the configuration file does not exist
§Returns
Self
- The instance of Quickner
§Errors
This function will return an error if the configuration file does not exist
pub fn add_document(&mut self, document: Document)
pub fn add_document_from_string(&mut self, text: &str)
pub fn add_entity(&mut self, entity: Entity)
Sourcepub fn process(&mut self, save: bool) -> Result<(), Box<dyn Error>>
pub fn process(&mut self, save: bool) -> Result<(), Box<dyn Error>>
Process the texts and entities, and annotate the texts with the entities. This method will return the annotations, and optionally save the annotations to a file.
§Arguments
self
- The instance of Quicknersave
- Whether to save the annotations to a file
§Example
use quickner::Quickner;
let quickner = Quickner::new(Some("./config.toml"));
quickner.process(true);
§Returns
Result<Annotations, Box<dyn Error>>
- The annotations
§Errors
This function will return an error if the configuration file does not exist This function will return an error if the entities file does not exist This function will return an error if the texts file does not exist
pub fn from_jsonl(path: &str) -> Quickner
pub fn from_spacy(path: &str) -> Quickner
pub fn spacy(&self, chunks: Option<usize>) -> Vec<Vec<(String, SpacyEntity)>>
Source§impl Quickner
impl Quickner
pub fn build_label_index(&mut self)
pub fn build_entity_index(&mut self)
pub fn document_hash(documents: &[Document]) -> HashMap<String, Document>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Quickner
impl RefUnwindSafe for Quickner
impl Send for Quickner
impl Sync for Quickner
impl Unpin for Quickner
impl UnwindSafe for Quickner
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
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>
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>
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