@ericlin
Nothing here yet.
Nothing here yet.
Apr 10, 2023 · 3 min read · When reading rust codes, you sometimes see File::open or f.read(). Why are some functions accessed with ::, and others with .? By taking a look at the source code for std::fs::File, we could see that these functions are defined either in impl File, o...
Join discussionApr 8, 2023 · 2 min read · 閱讀 rust 程式的時候偶爾會看到 File::open() 或是 f.read()。但為什麼有些功能是用 :: 呼叫,有些是用 . ? 翻開 std::fs::File 的原始碼,可以看到這些功能都是定義在 impl File 或是 impl SomeTrait for File 內: // src/std/fs.rs 精簡版 impl File { pub fn open(path: P) -> io::Result<File> {省略} pub fn create(pat...
Join discussionAug 19, 2022 · 9 min read · How jieba works, part 3 本篇將用 Part 2 介紹的隱藏式馬可夫模型與 Viterbi 演算法將剩下的字 (大、學、與、老、師、討、論、力、學) 分詞。 字的隱藏狀態 一個人的身體可以有健康、生病的隱藏狀態。那一個字可以有幾種?結巴的程式碼定義了四種隱藏狀態:詞首、詞中、詞尾、以及單獨存在,分別用 B, M, E, S 標示。這四種狀態其實就是字位於詞的不同位置。 例如: 我: S 『我』只有一個字,所以標示 S 單獨存在。 的: S 『的』只有一個字,所以標示...
Join discussionAug 19, 2022 · 3 min read · How jieba works, part 2 這篇將解釋何謂馬可夫模型 Markov model、隱藏式馬可夫模型 Hidden Markov model (HMM)、與 Viterbi 演算法。 馬可夫模型 Markov model 馬可夫模型是一個用來解釋偽隨機系統的模型。它假設未來事件只受到現在事件影響,不受更早事件影響。 範例:假設你是醫生,從你的臨床經驗來看,一個人身體前一天健康、今天也健康的機率是 0.7;前一天健康、今天生病的機率是 0.3;前一天生病、今天健康的機率是 0.4;...
Join discussion