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