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

Migrates text input rules from NormalizedString to SetOfNormalizedString #10882

Merged
merged 33 commits into from
Nov 2, 2020

Conversation

shavavo
Copy link
Contributor

@shavavo shavavo commented Oct 6, 2020

Overview

This PR does the following:
These changes are required to make rule inputs translatable.

  • Migrates text input rules from NormalizedString to SetOfNormalizedString
  • State migration of existing text input rules

@oppiabot
Copy link

oppiabot bot commented Oct 6, 2020

Assigning @DubeySandeep for the first-pass review of this pull request. Thanks!

@seanlip
Copy link
Member

seanlip commented Oct 6, 2020

Hi @shavavo! FYI -- frontend tests are failing? (Not sure how that happened -- aren't they checked pre-push?)

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @shavavo! Took a pass.

editDistance[i][j] = Math.min(
editDistance[i - 1][j - 1], editDistance[i][j - 1],
editDistance[i - 1][j]) + 1;
const levenshtein = (inputString, matchString) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start with a verb, and also be clearer that this is returning a boolean rather than the distance: hasEditDistanceEqualToOne or isDifferentByOneCharacter or hasExactlyOneTypo or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

warningsList.push({
type: AppConstants.WARNING_TYPES.ERROR,
message: (
`Answer group ${answerGroupIndex + 1} has multiple rules on ` +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on --> with

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if (rule.type === 'Contains') {
// Check if the current string contains any of the previously seen
// strings as a substring.
if (seenStringsContains.some(
(seenString) => currentString.includes(seenString)) ||
(seenString) => currentStrings.includes(seenString)) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong? Previously, the variable was a string, now it's an array. I think you're checking for something different here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

} else if (rule.type === 'StartsWith') {
// Check if the current string contains any of the previously seen
// strings as a prefix.
if (seenStringsStartsWith.concat(seenStringsContains).some(
(seenString) => currentString.indexOf(seenString) === 0)) {
(seenString) => currentStrings.indexOf(seenString) === 0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

warningsList.push({
type: AppConstants.WARNING_TYPES.ERROR,
message: `Rule ${ruleIndex + 1} from answer group ` +
`${answerGroupIndex + 1} will never be matched because it ` +
'is preceded by a \'FuzzyEquals\' rule with a matching input.'
});
}
seenStringsFuzzyEquals.push(currentString);
seenStringsFuzzyEquals.push(...currentStrings);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to update the tests...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"Contains": "contains {{x|NormalizedString}}",
"Equals": "is equal to {{x|NormalizedString}}, without taking case into account",
"FuzzyEquals": "is equal to {{x|NormalizedString}}, misspelled by at most one character"
"StartsWith": "starts with one of {{x|SetOfNormalizedString}}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change to "at least one of", ditto below where appropriate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@seanlip seanlip assigned shavavo and unassigned seanlip Oct 6, 2020
Copy link
Member

@DubeySandeep DubeySandeep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the codeowner files: core/domain/draft_upgrade_services*.py

@oppiabot
Copy link

oppiabot bot commented Oct 6, 2020

Unassigning @DubeySandeep since they have already approved the PR.

@oppiabot
Copy link

oppiabot bot commented Oct 6, 2020

Assigning @vojtechjelinek, @nithusha21, @aks681 for code owner reviews. Thanks!

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, confirming this looks good from a test-run perspective! Therefore giving LGTM, but @shavavo please note #10882 (review).

@kevintab95 kevintab95 removed their assignment Oct 21, 2020
Copy link
Contributor

@aks681 aks681 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm as codeowner

@aks681 aks681 removed their assignment Oct 24, 2020
@oppiabot oppiabot bot added the PR: LGTM label Oct 24, 2020
@shavavo shavavo requested a review from BenHenning October 25, 2020 01:51
@shavavo shavavo removed their assignment Oct 25, 2020
@oppiabot
Copy link

oppiabot bot commented Oct 26, 2020

Assigning @BenHenning for code owner reviews. Thanks!

@seanlip
Copy link
Member

seanlip commented Oct 26, 2020

Hi @shavavo -- could you please try running the coreEditorAndPlayerFeatures and extensions e2e suites locally? Those suites fail for me locally too and I think it's caused by this PR (i.e. it's not a flake).

Thanks!

@BenHenning
Copy link
Member

Hmm I think oppiabot mistook me for a code owner for some reason. @jameesjohn do you have any idea why that might be? I was a code owner at the beginning of this PR, but have since changed.

I'll cancel my review to avoid confusing it further. @shavavo feel free to re-assign me if you'd like me to do another review pass.

@BenHenning BenHenning removed their request for review October 27, 2020 06:26
@BenHenning BenHenning removed their assignment Oct 27, 2020
@kevintab95
Copy link
Member

Removing "LGTM" label since 1 more approval is required for this PR. Thanks!

@kevintab95
Copy link
Member

@srijanreddy98 PTAL!

@seanlip seanlip merged commit e69e919 into oppia:develop Nov 2, 2020
iramin pushed a commit to iramin/oppia that referenced this pull request Nov 7, 2020
…ing (oppia#10882)

* review comment from PR10246

* migration and frontend changes

* linter

* backend test fixes

* frontend tests

* styling

* coverage

* review & fixed e2e tests

* fit

* review

* tests

* todo comment

* fix comment

* e2e tests

* fix e2e tests

* fix e2e tests

Co-authored-by: shavavo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.