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

Extra Whitespace in Input Causes Incorrect Answer #3378

Open
greenmachine112 opened this issue Jun 5, 2024 · 1 comment
Open

Extra Whitespace in Input Causes Incorrect Answer #3378

greenmachine112 opened this issue Jun 5, 2024 · 1 comment

Comments

@greenmachine112
Copy link

When accepting manually typed input from users for translations, the user's answer is marked incorrect if there is any extra whitespace at the end of the input. This error is exclusive to trailing whitespace, as extra whitespace between or before words does not cause this issue. For example, when translating the phrase "El come pizza" to English, the correct translation "He eats pizza" is marked incorrect if entered as "He eats pizza " (with an extra space at the end).

Steps to Reproduce:
Navigate to the website and begin a lesson.
Enter the correct translation for any text input with an extra space at the end (i.e., "He eats pizza ").
Submit the answer.

Expected Result:
The app should trim any trailing whitespace from input before validation, and mark the translation "He eats pizza " as correct.

Actual Result:
The app notifies the user that a typo exists.

Impact:
This issue can be frustrating for users as it penalizes them for a minor formatting error that does not affect the correctness of the translation.

Severity:
Medium

Environment:

App Version: [insert app version here]
Operating System: [insert operating system here]
Device: [insert device model here]
Additional Information:
The issue appears to be related to how the app validates user input. It likely does a direct string comparison without trimming whitespace. rstrip(), or varibaleTrim() would work.

Attachments:
exhibit1
Screenshot of the incorrect answer message with extra whitespace in the input.

Suggested Fix:
Update the input validation logic to trim leading and trailing whitespace from user inputs before comparing them to the correct answer.

@twocs
Copy link

twocs commented Jun 23, 2024

The white space logic is in https://github.com/kantord/LibreLingo/blob/main/apps/answer-corrector/src/index.ts:8

const ignoreWhitespace = (form: string): string =>
  form.replace(/^\s+|\s+$/g, "").replace(/\s+/g, " ")

In principle, this will take all spaces (and tabs) at the beginning and end of a block of text and remove the white spaces. I tested on the animals on librelingo.app and was able to get a correct answer despite trailing white space. I do see the screenshot above does appear to demonstrate trailing whitespace causing an issue.

I will attach screenshots, but ultimately I would say more detail is required to understand the bug.

image
image

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