pub struct Focus {
pub query: Query,
/* private fields */
}Expand description
查询和从它派生的打分规则。
Fields§
§query: QueryImplementations§
Source§impl Focus
impl Focus
pub fn new(query: &str) -> Focus
Sourcepub fn note_seed_language(&mut self, lang: Option<&str>)
pub fn note_seed_language(&mut self, lang: Option<&str>)
记下种子页声明的语言。
Sourcepub fn found_english_home(&mut self)
pub fn found_english_home(&mut self)
记下抓到了本站的英文版首页(见 Self::is_language_portal)。
Sourcepub fn with_host(self, host: &str) -> Focus
pub fn with_host(self, host: &str) -> Focus
记下种子页的主机(见 Self::same_host)。
Sourcepub fn observe_page(&mut self, page: &PageSignal)
pub fn observe_page(&mut self, page: &PageSignal)
记下一页(正文命中的词、各方面的证据),调整词权重和本站统计量。抓到的每一页都要记 (包括无用页:正是它们说明哪些词常见)。
Sourcepub fn page_signal(
&self,
url: &Url,
title: Option<&str>,
markdown: &str,
links: usize,
lang: Option<&str>,
) -> PageSignal
pub fn page_signal( &self, url: &Url, title: Option<&str>, markdown: &str, links: usize, lang: Option<&str>, ) -> PageSignal
相关度的组成(见 [Self::page_relevance]):词权重变了以后按它重算。
pub fn relevance(&self, p: &PageSignal) -> f32
Sourcepub fn weights_moved(&mut self) -> bool
pub fn weights_moved(&mut self) -> bool
词权重和上次重新打分时比变得够多了(变化最大的词差 [RESCORE_DELTA] 以上):
排队链接的分数要按新权重重算。返回 true 时记下现在的权重。
Sourcepub fn link_score(
&self,
url: &Url,
anchor: Option<&str>,
context: Option<&str>,
parent: f32,
depth: usize,
) -> f32
pub fn link_score( &self, url: &Url, anchor: Option<&str>, context: Option<&str>, parent: f32, depth: usize, ) -> f32
一个链接的分数。parent 是所在页面的相关度,depth 是链接目标的深度。
Sourcepub fn link_signal(
&self,
url: &Url,
anchor: Option<&str>,
context: Option<&str>,
parent: PageSignal,
depth: usize,
) -> LinkSignal
pub fn link_signal( &self, url: &Url, anchor: Option<&str>, context: Option<&str>, parent: PageSignal, depth: usize, ) -> LinkSignal
链接分数的组成(见 Self::score):命中了哪些词、所在页面、URL 的形状和深度。
存下它,词权重变了以后不用再看一遍页面就能重算分数。
Sourcepub fn score(&self, s: &LinkSignal) -> f32
pub fn score(&self, s: &LinkSignal) -> f32
链接的分数:锚文本、URL、所在行按当前词权重的覆盖率,加上所在页面的相关度, 按 URL 的形状打折或给保底分,再按深度衰减。
Sourcepub fn learn(&mut self, s: &LinkSignal, hit: bool) -> bool
pub fn learn(&mut self, s: &LinkSignal, hit: bool) -> bool
记下一个链接抓回来的页面是否相关,更新链接权重。权重变了时返回 true, 排队的链接要按新权重重新打分。直接给定分数的链接(种子页、hreflang)没有特征,不学。
Sourcepub fn is_language_portal(&self, url: &Url) -> bool
pub fn is_language_portal(&self, url: &Url) -> bool
这一页是不是本站英文版的首页(/en/、/en.html、/top/en/),而且是第一个:
它是第二个首页,链接不多衰减一层(它下面的 /en/studies/ 按一级栏目算,见 [section])。
Auto Trait Implementations§
impl Forget for Focus
impl Freeze for Focus
impl RefUnwindSafe for Focus
impl Send for Focus
impl Sync for Focus
impl Unpin for Focus
impl UnsafeUnpin for Focus
impl UnwindSafe for Focus
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