pub struct Dictionary {
pub language: String,
/* private fields */
}Expand description
Cifra stores word dictionaries in a local database. This class is a wrapper to not to deal directly with that database.
This class is intended to be used as a context manager so you don’t have to deal with opening and closing this dictionary. So, call this method as a context manager, it will return this instance so you can call further methods to manage its words.
Fields§
§language: StringImplementations§
Source§impl Dictionary
impl Dictionary
Sourcepub fn remove_dictionary<T>(_language: T) -> Result<()>
pub fn remove_dictionary<T>(_language: T) -> Result<()>
Remove given language from database.
Be aware that all its words will be removed too.
§Parameters:
- language: Language to remove from database.
Sourcepub fn get_dictionaries_names() -> Result<Vec<String>>
pub fn get_dictionaries_names() -> Result<Vec<String>>
Get languages dictionaries present at database.
§Returns:
- A list with names of dictionaries present at database.
Sourcepub fn new<T>(_language: T, create: bool) -> Result<Self>
pub fn new<T>(_language: T, create: bool) -> Result<Self>
§Parameters:
- language: Language you want to manage its words.
- create: Whether this language should be created in database if not present yet. It defaults to False. If it is set to False and language is not already present at database then a dictionaries.NotExistingLanguage exception is raised, but if it is set to True then language is registered in database as a new language.
Sourcepub fn session(&self) -> &DatabaseSession
pub fn session(&self) -> &DatabaseSession
Get open session for current dictionary database.
Sourcepub fn add_word<T>(&mut self, _word: T)
pub fn add_word<T>(&mut self, _word: T)
Add given word to dictionary.
If word is already present at dictionary, do nothing.
§Parameters:
- word: word to add to dictionary.
Sourcepub fn add_multiple_words(&mut self, _words: &HashSet<String>)
pub fn add_multiple_words(&mut self, _words: &HashSet<String>)
Sourcepub fn remove_word<T>(&mut self, _word: T)
pub fn remove_word<T>(&mut self, _word: T)
Remove given word from dictionary.
If word is not already present at dictionary, do nothing.
§Parameters:
- word: word to remove from dictionary.
Sourcepub fn word_exists<T>(&self, _word: T) -> bool
pub fn word_exists<T>(&self, _word: T) -> bool
Sourcepub fn populate<T>(&mut self, file_pathname: T) -> Result<()>
pub fn populate<T>(&mut self, file_pathname: T) -> Result<()>
Read a file’s words and stores them at this language database.
§Parameters:
- file_pathname: Absolute path to file with text to analyze.
Sourcepub fn get_words_with_pattern<T>(&self, pattern: T) -> Result<Vec<String>>
pub fn get_words_with_pattern<T>(&self, pattern: T) -> Result<Vec<String>>
Sourcepub fn get_words_presence(&self, _words: &HashSet<String>) -> f64
pub fn get_words_presence(&self, _words: &HashSet<String>) -> f64
Sourcepub fn get_all_words(&self) -> Result<Vec<String>>
pub fn get_all_words(&self) -> Result<Vec<String>>
Get a list of every word present at dictionary.
Auto Trait Implementations§
impl !Freeze for Dictionary
impl !RefUnwindSafe for Dictionary
impl Send for Dictionary
impl !Sync for Dictionary
impl Unpin for Dictionary
impl UnwindSafe for Dictionary
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> 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 moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
&self to an expression for Diesel’s query builder. Read more