Open bunny-therapist opened 4 weeks ago
Note that I may very well be wrong here. I just can't make sense of this duplication.
@xamgore I see you noticed the same thing: https://github.com/xamgore/yake-rust/blob/master/yake_rust/src/lib.rs#L243
Would you like to proceed on this together? Assigned you a contributor anyway.
I am not sure how to organize this. I have been tracking bugs all day and I think I found and fixed a few. Right now I am working on another...
Ah, I see. I'll adapt your changes at my branch.
This is definitely a bug. The contexts should be initialized with empty vectors so we do not have duplicates. I fixed it in my fork: https://github.com/bunny-therapist/yake-rust
I am getting much closer to the LIAAD/yake results, but it is hard for me because I am at this point working with multiple versions of the code and it is very hard for me to track everything.
I will create issues for the other bugs I have found as well I think.
Stick to your repo then, I'll just cherry-pick the commits. I'm more concerned of the design & maintainability.
The function context_building
The piece of code that adds entries to the contexts appears to add each thing twice. If there is no entry for "word", it creates an entry with ([w], []), then on the next line it adds w so we get it twice: ([w, w], []). Same with the entry for "w", it creates ([], [word]), then adds word so we get it twice, ([], [word, word]).
Correct me if I am wrong ,but I suspect that there should just be one entry (the context 0/1 elements appear to be incoming/outgoing edges for the word node) and that this is a mistake?
Should the initialization via
or_insert
not just create two empty vectors, then let the next line add it?As a second point, I don't understand the leading if statement inside the
words.iter()
loop. It iteratesword
over the elements ofwords
, so surelywords.contains(word)
is always true?This is what the function would look like after fixing the entries and removing the conditional: