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

Better Fix Logic for TwoWord Validator #511

Merged
merged 5 commits into from
Dec 13, 2023
Merged

Better Fix Logic for TwoWord Validator #511

merged 5 commits into from
Dec 13, 2023

Conversation

CalebCourier
Copy link
Collaborator

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 and word -> the word respectively

There'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.

Copy link

vercel bot commented Dec 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
guardrails ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2023 9:10pm

@CalebCourier CalebCourier requested a review from a team December 13, 2023 21:03
@zsimjee zsimjee merged commit 67529d1 into main Dec 13, 2023
38 checks passed
@CalebCourier CalebCourier deleted the two-word-fix branch January 9, 2024 19:17
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