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

Incorrect order of answers when using the wildcard '*' in DAWG #11

Open
lifmore opened this issue Oct 14, 2022 · 2 comments
Open

Incorrect order of answers when using the wildcard '*' in DAWG #11

lifmore opened this issue Oct 14, 2022 · 2 comments
Assignees

Comments

@lifmore
Copy link

lifmore commented Oct 14, 2022

Hi,

I wonder if there is a small issue in the file automata.py, function __words_with_wildcard, between lines 128 and 147, when the case letter=='*' is processed.

If the dictionary is made of, for example, "CHIAC" and "CHIC", and the query is "CHI*C", the result will be return in an incorrect alphabetical order : "CHIC" then "CHIAC".

This is because the case words_at_current_level is processed before checking the children.

So, for "CHI*C",

  • words_at_current_level will first find "CHIC"
  • then the loop for child in node.children will find "CHIAC", resulting in an incorrect order of answers.

Any idea? Or maybe did I misunderstood the code?

Best,
Lionel

@lifmore
Copy link
Author

lifmore commented Oct 15, 2022

I was able to fix it by modifying the __words_with_wildcard function.
The key idea is to process the words_at_current_level case in the middle of the "for child in node.children:" loop, at the right timing, and not before or after the loop.

@aosingh aosingh self-assigned this Oct 17, 2022
@aosingh
Copy link
Owner

aosingh commented Oct 17, 2022

Thank you @lifmore

I just saw this. I will try to reproduce the issue and get back to you.

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

No branches or pull requests

2 participants