Better Fix Logic for TwoWord Validator #511
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously if the TwoWord validator failed because the input didn't contain any spaces we returned a fix_value with the same non-passing string.
Now we make best efforts to extract two words from the input string and, if that fails, follow the same pattern we use in ValidLength by simply repeating the input string.
This approach isn't perfect because the two words we extract may not represent a complete thought, and obviously repeating the same word twice isn't as coherent as it could be.
Future optimizations could include dropping articles from the middle of the word list to try to target more meaningful words, and potentially auto prefixing an article when the input is truly a single word:
i.e.
over-the-credit-limit
->over-credit
andword
->the word
respectivelyThere's also a small bug fix in the reask utils to use a copy when fixing validation outcomes. This is important for tracking what originally came out of the validation process.
The same bug caused a need to fix the last panel of the tree display if we passed validation via fixes.