-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
levenshtein: LevenshteinState, usize input distance #99
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Unfortunately, I don't think I will be merging breaking changes any time soon. :-(
@@ -111,12 +111,10 @@ impl Levenshtein { | |||
#[inline] | |||
pub fn new( | |||
query: &str, | |||
distance: u32, | |||
distance: usize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please say why? This seems trivial to me, and there is no way i'm going to put out a breaking change release for something like this given that I just released 0.4
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense in combination with the main change - LevenshteinState
- to make all distance types consistent.
impl Automaton for Levenshtein { | ||
type State = Option<usize>; | ||
type State = Option<LevenshteinState>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I'm not putting out a 0.5
release for this. :-(
Other ideas:
- Keep this PR on hold until I'm ready for another breaking change release.
- Create a new levenshtein automaton type.
- Put this automaton in a new crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would choose 1. option - on hold.
I can inline updated automaton into my project - I don't need it in the official fst
release. So merge it when you want and I think this PR can be used also as an example when other users want to use automaton states.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks for understanding.
src/set.rs
Outdated
("fozb".to_string(), Some(83)), | ||
("foo".to_string(), Some(LevenshteinState { state_idx: 183, distance: Some(0) })), | ||
("foob".to_string(), Some(LevenshteinState { state_idx: 123, distance: Some(1) })), | ||
("fozb".to_string(), Some(LevenshteinState { state_idx: 83, distance: Some(2) })), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap lines to 79 columns inclusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make all changed lines shorter.
FYI: When you add error_on_line_overflow = true
and error_on_unformatted = true
into rustfmt.toml
and run cargo +nightly fmt --all
, it reports 36 errors.
Motivation
Map::search_with_state
.Breaking changes
Levenshtein::new(query: &str, distance: u32)
changed todistance: usize
.LevenshteinState
.Tests
cargo test --features levenshtein