-
Notifications
You must be signed in to change notification settings - Fork 382
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
CLDR-15817 Update Example Generator #3978
CLDR-15817 Update Example Generator #3978
Conversation
Incomplete draft that creates a new method that calls createExampleHtml passing a list as an additional argument and updates one of the handlers ( |
@haytenf to fix the formatting you can run this: |
tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java
Outdated
Show resolved
Hide resolved
tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! The code looks cleaner with your changes, except a couple of commented-out bits of code that should be removed. Hurray, the tests all pass! If there were lots of time to do more work on this I would suggest adding another unit test or two, but that doesn't seem essential. A couple screenshots of examples would be nice to see in the PR or the ticket to confirm the examples look the same as they did before the refactoring
tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java
Outdated
Show resolved
Hide resolved
tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java
Outdated
Show resolved
Hide resolved
tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. I suggest not changing the main dispatch to a switch in a different PR; that will make it easier to test.
Also, for refactorings like this, once you are statisfied with this, you can pull in the original file as ExampleGeneratorOld.java, and write a test case that checks that the results are identical for old and new, iterating across all locales, and iterating across all paths in that locale. That's a small amount of code that gives us a great deal of confidence!
@btangmu @srl295 @macchiati In the most recent commit, I've added a unit test comparing the old/new example generator, cleaned up the commented out code, and added before/after screenshots that show the example doesn't change. I also wanted to explain a change I made that isn't related to the purpose of this ticket. With the new unit test I added ( I also wanted to note for that the unit test, |
@@ -1215,7 +1214,7 @@ private void handleMinimalPairs( | |||
} | |||
|
|||
private String getOtherGender(String gender) { | |||
if (gender == null) { | |||
if (gender == null || grammarInfo == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
that's a puzzle -- does anyone know why? |
locally or on the github build? if it's the github build could have just been random. |
I'm still not sure what could be the issue. It was an issue locally--it ended up running for 12+ hours at which point it ran into a runtime exception/memory error from running out of heap space. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good and I think it's an improvement
examples.add(""); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to add a ""
example here? or just to exit without adding anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Yes, i think it makes sense to just return
in this case.
tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGeneratorOld.java
Outdated
Show resolved
Hide resolved
@@ -2076,4 +2079,27 @@ private String getResult(String starredPath, String attr) { | |||
public String sampleAttrAndValue(PathStarrer ps, final String separator, String value) { | |||
return ps.getAttributesString(separator) + "➔«" + value + "»"; | |||
} | |||
|
|||
public void TestRefactoring() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, i see it's for the temporary test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. All locales X all resolved paths will be way too much.
Actually what you probably want to do here is to limit it by coverage and pathheader. I'll get some sample code for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code (will need some setup) should show whether a path would even be shown to users or not. If not, it should be skipped from the test:
// adapted from STFactory.isValidSurveyToolVote
PathHeader.Factory phf = PathHeader.getFactory(null); // do this once!
private boolean isValidSurveyToolVote(String xpath) {
PathHeader ph = phf.fromPath(xpath); // will need a
PathHeaderFactory
if (ph == null) return false;
if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.DEPRECATED) return false;
if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.HIDE
|| ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.READ_ONLY) {
return false;
}
if (supplementalDataInfo.getCoverageValue(xpath, locale.getBaseName())
> org.unicode.cldr.util.Level.COMPREHENSIVE.getLevel()) {
return false;
}
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I'll revise to test over only the paths that'd be shown to users. Even over that reduced set of paths, and considering the extra check needed to determine if a path shown to users, I'm guessing the resolved files may still be too large to test over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think ExampleGeneratorOld.java shouldn't be in the PR
@srl295 @btangmu @macchiati I've modified the test so that it only checks the paths that are shown to users. If that's looking ok, I can remove the old file ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good
tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I think if you remove teh ExampleGeneratorOld and TestRefactoring this is ready to go - test passes!!
Co-authored-by: Steven R. Loomis <[email protected]>
5c98aa7
into
unicode-org:CLDR-15817-Update-ExampleGenerator
@haytenf Thanks! 🎉 |
Thank you! |
Co-authored-by: haytenf <[email protected]>
) Co-authored-by: haytenf <[email protected]>
Co-authored-by: haytenf <[email protected]>
CLDR-15817
ALLOW_MANY_COMMITS=true