Solution Wanted: Code for Cloze Question
A cloze question is an exercise used to help test a student's knowledge of a subject. It involves a passage of text with certain words omitted, and the student is asked to identify the missing words. Now, I need a generator to mask a certain token in a given description.
Here, I've created some tests (in JUnit) to describe my need. Can you implement the "ClozeTestUtils.clozeReplacement" in my test code so that all the test cases will pass?
领英推荐
public class ClozeDescriptionTest {
@ParameterizedTest
@CsvSource({
"moon, partner of earth, partner of earth",
"sedition, word sedition means this, word [...] means this",
"sting, existing, existing",
"鳴く, 羊はなんて鳴くの?, 羊はなんて[...]の?",
"rapport, 你知道rapport是什么吗?, 你知道[…]是什么吗?",
"олет, Это самолет, Это самолет",
})
void clozeDescription(String token, String description, String expectedClozeDescription) {
String actual = ClozeTestUtils.clozeReplacement(token, description);
assertThat(actual, equalTo(expectedClozeDescription));
}
}
I have sent the code and question to ChatGPT for assistance, but it was not able to pass all test cases (ChatGPT 4 failed as well). However, this is not a cause for concern, as the primary goal of test-driven development is to have just enough code to pass existing tests, with the expectation that additional tests will be added later. But ChatGPT also tries to provide solutions to the test cases I don't have, and that made me uneasy. I trust you must know what it means to have just enough code to pass all the existing tests!
Of course, the solution is not limited to using regex. It was intended for reducing scope for AI to focus.
Give it a try, and good luck!
Director of Software Engineering | Empowers teams to perform at their best | Elevating lives daily
1 年for this input "олет, Это самолет, Это самолет", why the expected is not "Это сам[...]" ?