use crate::common::{PhraseLength, Punctuation, Stopwords, Text, WindowSize};
type DampingFactor = f32;
type Tolerance = f32;
pub enum TextRankParams<'a> {
WithDefaults(Text<'a>, Stopwords<'a>),
WithDefaultsAndPhraseLength(Text<'a>, Stopwords<'a>, PhraseLength),
All(
Text<'a>,
Stopwords<'a>,
Punctuation<'a>,
WindowSize,
DampingFactor,
Tolerance,
PhraseLength,
),
}
impl<'a> TextRankParams<'a> {
pub fn get_params(
&self,
) -> (
Text,
Stopwords,
Punctuation,
WindowSize,
DampingFactor,
Tolerance,
PhraseLength,
) {
match self {
TextRankParams::WithDefaults(text, stop_words) => {
(text, stop_words, None, 2, 0.85, 0.00005, None)
}
TextRankParams::WithDefaultsAndPhraseLength(text, stop_words, phrase_length) => {
(text, stop_words, None, 2, 0.85, 0.00005, *phrase_length)
}
TextRankParams::All(
text,
stop_words,
punctuation,
window_size,
damping_factor,
min_diff,
phrase_length,
) => (
text,
stop_words,
*punctuation,
*window_size,
*damping_factor,
*min_diff,
*phrase_length,
),
}
}
}