Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow users to load custom hmm model #92

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

name1e5s
Copy link

close #48

@codecov
Copy link

codecov bot commented Dec 18, 2022

Codecov Report

Merging #92 (64158fc) into main (38fe280) will increase coverage by 1.17%.
The diff coverage is 52.63%.

@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
+ Coverage   86.41%   87.59%   +1.17%     
==========================================
  Files           8        7       -1     
  Lines        1067      693     -374     
==========================================
- Hits          922      607     -315     
+ Misses        145       86      -59     
Impacted Files Coverage Δ
src/lib.rs 92.56% <ø> (+6.74%) ⬆️
src/hmm.rs 81.95% <52.63%> (-12.79%) ⬇️
src/keywords/tfidf.rs 83.82% <0.00%> (-3.82%) ⬇️
src/keywords/textrank.rs 84.09% <0.00%> (-2.83%) ⬇️
src/sparse_dag.rs 100.00% <0.00%> (ø)
tests/test_wasm.rs

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Owner

@messense messense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is the best way to do it. How about making viterbi a method of HmmModel and let Jieba own a HmmModel?

struct Jieba {
    hmm_model: Option<HmmModel>,
    ...
}

impl Jieba {
    pub fn set_hmm_model(&mut self, hmm_model: HmmModel) -> &mut Self {
        ...
    }
}

struct HmmModel {
    ...
}

impl HmmModel {
    pub fn new(..) -> Self {
        todo!()
    }
}

#[cfg(feature = "default-hmm-model")]
impl Default for HmmModel {
    fn default() -> HmmModel {
        // load default hmm model
    }
}

cedarwood = "0.4"
ordered-float = { version = "3.0", optional = true }
once_cell = "1"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no point in use both lazy_static and once_cell, please also replace lazy_static with once_cell

@@ -30,17 +30,18 @@ required-features = ["tfidf", "textrank"]
regex = "1.0"
lazy_static = "1.0"
phf = "0.11"
hashbrown = { version = "0.12", default-features = false, features = ["inline-more"] }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need a benchmark result to justify it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if instead HMMModel should be a seprate struct and that Jieba's interface should be expanded to be

cut()
hmm_cut()

Will discussion back in #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow load custom HMM model
3 participants