pub struct TextFilter {
min_length: usize,
skip_links: bool,
skip_code_blocks: bool,
custom_filters: Vec<Regex>,
number_pattern: Regex,
url_pattern: Regex,
email_pattern: Regex,
code_pattern: Regex,
skip_words: HashSet<String>,
}Expand description
文本过滤器
Fields§
§min_length: usize最小文本长度
skip_links: bool跳过链接文本
skip_code_blocks: bool跳过代码块
custom_filters: Vec<Regex>自定义过滤规则
number_pattern: Regex数字模式正则
url_pattern: RegexURL模式正则
email_pattern: Regex邮箱模式正则
code_pattern: Regex代码模式正则
skip_words: HashSet<String>常见的不需要翻译的词汇
Implementations§
Source§impl TextFilter
impl TextFilter
Sourcepub fn new(config: &TranslationConfig) -> Self
pub fn new(config: &TranslationConfig) -> Self
创建新的文本过滤器
Sourcepub fn should_translate(&self, text: &str) -> bool
pub fn should_translate(&self, text: &str) -> bool
判断文本是否应该翻译
Sourcepub fn analyze_text(&self, text: &str) -> TextAnalysis
pub fn analyze_text(&self, text: &str) -> TextAnalysis
分析文本的可翻译性
Sourcefn is_version_like(&self, text: &str) -> bool
fn is_version_like(&self, text: &str) -> bool
检查是否类似版本号
Sourcefn is_html_entity(&self, text: &str) -> bool
fn is_html_entity(&self, text: &str) -> bool
检查是否为HTML实体
Sourcefn calculate_confidence(&self, text: &str) -> f32
fn calculate_confidence(&self, text: &str) -> f32
计算翻译置信度
Sourcefn detect_language_hint(&self, text: &str) -> LanguageHint
fn detect_language_hint(&self, text: &str) -> LanguageHint
检测语言提示
Sourcefn get_skip_reasons(&self, text: &str) -> Vec<String>
fn get_skip_reasons(&self, text: &str) -> Vec<String>
获取跳过原因
Auto Trait Implementations§
impl Freeze for TextFilter
impl RefUnwindSafe for TextFilter
impl Send for TextFilter
impl Sync for TextFilter
impl Unpin for TextFilter
impl UnwindSafe for TextFilter
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