Skip to main content

ExtractorConfig

Struct ExtractorConfig 

Source
pub struct ExtractorConfig {
    pub score_threshold: f32,
    pub cluster_depth: usize,
    pub cluster_min_size: usize,
    pub min_text_len: usize,
    pub use_url_rule: bool,
    pub non_article_paths: Vec<String>,
}
Expand description

提取器配置,按需调整以适配不同站点。

§默认值

字段默认值说明
score_threshold1.5低于此分的链接会被过滤
cluster_depth4DOM 路径签名向上遍历层数
cluster_min_size4聚类大小 >= 此值视为强信号
min_text_len8锚文本短于此值扣分
use_url_ruletrue是否开启 UrlRule 辅助信号
non_article_paths24 条默认路径/people//about/
use crawlkit_parser::ExtractorConfig;

// 低阈值模式:捕获更多候选链接
let config = ExtractorConfig {
    score_threshold: 0.5,
    min_text_len: 4,
    ..ExtractorConfig::default()
};

// 严格模式:只保留高置信度链接
let strict = ExtractorConfig {
    score_threshold: 3.0,
    cluster_min_size: 6,
    ..ExtractorConfig::default()
};

Fields§

§score_threshold: f32

最终判定为“文章链接“的分数阈值

§cluster_depth: usize

向上查找父节点计算路径签名的层数(越大越精细,但也越容易把 结构略有差异的同类项拆散)

§cluster_min_size: usize

一个聚类至少要有多少条链接,才被视为“列表结构“强信号

§min_text_len: usize

锚文本短于此长度的链接会被判定为可能是导航/按钮而非标题

§use_url_rule: bool

是否叠加 UrlRule 的正则规则作为附加信号

§non_article_paths: Vec<String>

URL 路径关键词惩罚列表(如 /people/ /about/),可追加站点自定义路径

Trait Implementations§

Source§

impl Clone for ExtractorConfig

Source§

fn clone(&self) -> ExtractorConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExtractorConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExtractorConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.