Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sven-oly
Copy link
Collaborator

Fixing problems with number format data generation and executors.

Starting with NodeJS.

@sven-oly
Copy link
Collaborator Author

Also clean up regex expressions in collation data generator.

@sven-oly
Copy link
Collaborator Author

The C++ number formatter is now working, classifying some problems as "unsupported".

@sven-oly
Copy link
Collaborator Author

ICU4J now has no errors or test failures.

Comment on lines 234 to 235
std::regex check1("(0+0.#+E)");
std::regex check2("(^.0#*E)");
Copy link
Collaborator

Choose a reason for hiding this comment

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

escape period in regex

Comment on lines 136 to 138
Pattern check1 = Pattern.compile("0+0.#+E");
Matcher matcher1 = check1.matcher(input.pattern);
Pattern check2 = Pattern.compile("^.0#*E");
Copy link
Collaborator

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)");
Copy link
Collaborator

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.
Copy link
Collaborator

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",
Copy link
Collaborator

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.

Copy link
Collaborator Author

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?


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.
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

const scale_value = parseFloat(match_scale[1]);
input = input * scale_value;
}
//
Copy link
Collaborator

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?

}
}
}
// Check for skelection terms that are not supported
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// 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",
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops!

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

Successfully merging this pull request may close these issues.

3 participants