pub struct KeywordExtractionModel<'a> {
pub sentence_embeddings_model: SentenceEmbeddingsModel,
pub tokenizer: StopWordsTokenizer<'a>,
/* private fields */
}Expand description
§KeywordExtractionModel to extract keywords from input texts
It contains a sentence embeddings model to compute word-document similarities, a tokenizer to define a keyword candidates list and a scorer to rank these keywords.
sentence_embeddings_model: Sentence embeddings modeltokenizer: tokenizer used to generate the list of candidates (differs from the transformer tokenizer)
Fields§
§sentence_embeddings_model: SentenceEmbeddingsModel§tokenizer: StopWordsTokenizer<'a>Implementations§
Source§impl<'a> KeywordExtractionModel<'a>
impl<'a> KeywordExtractionModel<'a>
Sourcepub fn new(
config: KeywordExtractionConfig<'a>,
) -> Result<KeywordExtractionModel<'a>, RustBertError>
pub fn new( config: KeywordExtractionConfig<'a>, ) -> Result<KeywordExtractionModel<'a>, RustBertError>
Build a new KeywordExtractionModel
§Arguments
config-KeywordExtractionConfigobject containing a sentence embeddings configuration and tokenizer-specific options
§Example
use rust_bert::pipelines::keywords_extraction::KeywordExtractionModel;
let keyword_extraction_model = KeywordExtractionModel::new(Default::default())?;Sourcepub fn get_tokenizer(&self) -> &TokenizerOption
pub fn get_tokenizer(&self) -> &TokenizerOption
Get a reference to the model tokenizer.
Sourcepub fn get_tokenizer_mut(&mut self) -> &mut TokenizerOption
pub fn get_tokenizer_mut(&mut self) -> &mut TokenizerOption
Get a mutable reference to the model tokenizer.
Sourcepub fn predict<S>(
&self,
inputs: &[S],
) -> Result<Vec<Vec<Keyword>>, RustBertError>
pub fn predict<S>( &self, inputs: &[S], ) -> Result<Vec<Vec<Keyword>>, RustBertError>
Extract keywords from a list of input texts.
§Arguments
inputs- slice of string-like input texts to extract keywords from
§Returns
Result<Vec<Vec<Keyword>>, RustBertError>containing a list of keyword for each input text
§Example
use rust_bert::pipelines::keywords_extraction::KeywordExtractionModel;
let keyword_extraction_model = KeywordExtractionModel::new(Default::default())?;
let input = [
"This is a first sentence to extract keywords from.",
"Some keywords will be extracted from this text too.",
];
let output = keyword_extraction_model.predict(&input);Auto Trait Implementations§
impl<'a> !Freeze for KeywordExtractionModel<'a>
impl<'a> RefUnwindSafe for KeywordExtractionModel<'a>
impl<'a> Send for KeywordExtractionModel<'a>
impl<'a> !Sync for KeywordExtractionModel<'a>
impl<'a> Unpin for KeywordExtractionModel<'a>
impl<'a> UnwindSafe for KeywordExtractionModel<'a>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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