-
-
Notifications
You must be signed in to change notification settings - Fork 13
Updating number format data generation and NodeJS number_fmt #468
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
base: main
Are you sure you want to change the base?
Conversation
Also clean up regex expressions in collation data generator. |
The C++ number formatter is now working, classifying some problems as "unsupported". |
ICU4J now has no errors or test failures. |
executors/cpp/number_fmt.cpp
Outdated
std::regex check1("(0+0.#+E)"); | ||
std::regex check2("(^.0#*E)"); |
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.
escape period in regex
Pattern check1 = Pattern.compile("0+0.#+E"); | ||
Matcher matcher1 = check1.matcher(input.pattern); | ||
Pattern check2 = Pattern.compile("^.0#*E"); |
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.
escape period in regex
|
||
// Check unsupport options in skeleton | ||
if (input.skeleton != null) { | ||
Pattern check_unnessary = Pattern.compile("rounding-mode-(unnecessary|half-odd)"); |
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.
Check if rounding-mode-unnecessary
is unsupported or not. It appears to exist in Java: NumberFormatterSettings
However, in that enum, there is no HALF_ODD
, only HALF_EVEN
"error_detail", | ||
json_object_new_string(pattern.c_str())); | ||
|
||
// Nothing more to do here. |
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.
See if the options UNNECESSARY
and HALF_ODD
should be used, as they currently are here in C++, or not.
const unsupported_rounding_modes = [ | ||
"halfOdd", |
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.
After checking whether HALF_ODD
and UNNECESSARY
are supported options or not in ICU4C, double check whether that accords with here in JS where they are currently listed as unsupported.
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.
HALF_ODD and UNNECESSARY are definitely defined here: https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/unumberoptions_8h.html#a2f46653ee48f5d8d5b8e67d4a1b8230a
The question about "unnecessary" and "inexact" are if we can create and use a test that is meaningful?
executors/node/numberformat.js
Outdated
|
||
testDecimalFormat: function(json, doLogInput) { | ||
const node_version = process.version; | ||
const label = json['label']; | ||
const skeleton = json['skeleton']; | ||
|
||
const pattern = json['pattern']; | ||
const rounding = json['roundingMode']; | ||
// Leave input as string unless it is adjusted. |
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 comment line is confusing. Remove. It's written about input
, which is a float, and this PR is adding input_as_string
, which seems straightforward when looking at the code.
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.
Restructured this a bit to only use input as floating value in the special cases of percent and scale options.
executors/node/numberformat.js
Outdated
const scale_value = parseFloat(match_scale[1]); | ||
input = input * scale_value; | ||
} | ||
// |
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.
What happened to the common?
executors/node/numberformat.js
Outdated
} | ||
} | ||
} | ||
// Check for skelection terms that are not supported |
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.
// Check for skelection terms that are not supported | |
// Check for skeleton terms that are not supported |
@@ -159,7 +159,8 @@ | |||
"description": "rounding mode to be used", | |||
"enum": ["ceil", "floor", "expand", "trunc", | |||
"halfCeil", "halfFloor", "halfExpand", | |||
"halfTrunc", "halfEven", | |||
"halfTrunc", "halfEven", "halfOdd", | |||
"floor", "ceil", |
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.
Why are floor
and ceil
being duplicated? See line 160
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.
Oops!
Fixing problems with number format data generation and executors.
Starting with NodeJS.