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

feat: add load_default_dict, clear, has_word, remove_word methods #118

Closed
wants to merge 10 commits into from

Conversation

snowyu
Copy link
Contributor

@snowyu snowyu commented Jan 15, 2025

No description provided.

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.24%. Comparing base (c609223) to head (72c07c5).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
+ Coverage   84.79%   85.24%   +0.45%     
==========================================
  Files           9        9              
  Lines        2045     2108      +63     
==========================================
+ Hits         1734     1797      +63     
  Misses        311      311              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented Jan 15, 2025

CodSpeed Performance Report

Merging #118 will not alter performance

Comparing snowyu:main (72c07c5) with main (c609223)

Summary

✅ 10 untouched benchmarks

@messense messense requested review from Copilot and messense January 15, 2025 02:07

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (5)

src/lib.rs:370

  • The code for updating the longest word length is commented out. This might cause the longest word length to be incorrect after removing a word. Consider uncommenting and ensuring the logic is correct.
// let word_len = word.chars().count();

src/lib.rs:286

  • Ensure that the clear method is covered by tests to verify that it correctly clears all data.
pub fn clear(&mut self) {

src/lib.rs:314

  • Ensure that the load_default_dict method is covered by tests to verify that it correctly loads the default dictionary.
pub fn load_default_dict(&mut self) {

src/lib.rs:330

  • Ensure that the has_word method is covered by tests to verify that it correctly checks for the existence of a word.
pub fn has_word(&self, word: &str) -> bool {

src/lib.rs:361

  • Ensure that the remove_word method is covered by tests to verify that it correctly removes a word and updates the total frequency.
pub fn remove_word(&mut self, word: &str) -> bool {
@snowyu
Copy link
Contributor Author

snowyu commented Jan 15, 2025

  • load_dict should be named add_dict makes more meaningful.
  • word_id should probably be generated with xxhash32.

src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@messense
Copy link
Owner

messense commented Jan 21, 2025

Thanks for the PR, I've manually merged changes from this PR into main except remove_word which is probably not a good idea to expose with the current internal.

@messense messense closed this Jan 21, 2025
@snowyu
Copy link
Contributor Author

snowyu commented Jan 22, 2025

@messense

BTW: the remove_word has its usage scenarios, for example, there is an error word (今天天气) in the default dictionary and you need to remove it.

Oh I just saw the issue #114 now.

@messense
Copy link
Owner

messense commented Jan 22, 2025 via email

@snowyu
Copy link
Contributor Author

snowyu commented Jan 22, 2025

How about fixing the default dict file instead for now?

It's too hard. It'll take a lot of time to proofread the words one by one. Maybe you can use the AI to correct some.

But maybe the #114' is another story.

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.

2 participants