pub trait StrSimWithTokenizer<T>: StrSim<T> {
// Required methods
fn similarity(&self, key: &str, query: &str) -> Result<f64, StrSimError>;
fn similarity_pre_tok1(
&self,
key: &str,
tokenized_query: &T,
) -> Result<f64, StrSimError>;
fn tokenize(&self, str: &str) -> T;
fn tokenize_list(&self, strs: &[&str]) -> Vec<T>;
}Required Methods§
Sourcefn similarity(&self, key: &str, query: &str) -> Result<f64, StrSimError>
fn similarity(&self, key: &str, query: &str) -> Result<f64, StrSimError>
Calculate the similarity between two strings. Usually, the similarity function is symmetric so key and query can be swapped. However, some functions such as monge-elkan are not symmetric, so key and query takes specific meaning: key is the value in the database and query is the search query from the user.
The return value is a likelihood between 0 and 1.
§Arguments
keythe value in the database (e.g., entity label)querythe search query from the user (e.g., cell in the table)
Sourcefn similarity_pre_tok1(
&self,
key: &str,
tokenized_query: &T,
) -> Result<f64, StrSimError>
fn similarity_pre_tok1( &self, key: &str, tokenized_query: &T, ) -> Result<f64, StrSimError>
Calculate the similarity with the query’s already been pre-tokenized
Sourcefn tokenize_list(&self, strs: &[&str]) -> Vec<T>
fn tokenize_list(&self, strs: &[&str]) -> Vec<T>
Tokenize a list of strings into a list of tokens used for this method.