Skip to content

Commit

Permalink
Rust collation update - simplify code. (#156)
Browse files Browse the repository at this point in the history
* Change from rust to ICU4X in Summary

* Revise ICU4X collator call

* Revise ICU4X collator call
  • Loading branch information
sven-oly authored Jan 4, 2024
1 parent 88ea32f commit d819cfa
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 24 deletions.
8 changes: 1 addition & 7 deletions executors/rust/1.3/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ pub fn run_collation_test(json_obj: &Value) -> Result<Value, String> {

let comparison = collator.compare(str1, str2);

let result = comparison.is_le();

// TODO: How to do this easier?
let mut result_string = true;
if !result {
result_string = false;
}
let result_string = comparison.is_le();

let mut comparison_number: i16 = 0;
if comparison == Ordering::Less {
Expand Down
79 changes: 62 additions & 17 deletions verifier/testreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,68 @@ def characterize_failures_by_options(self, tests, result_type):
'notation', 'compactDisplay', 'style', 'currency', 'unit', 'roundingMode', ]
for key in key_list:
try:
locale = input_data.get('locale')
except:
locale = None
if locale:
if locale in results['locale']:
results['locale'][locale].append(label)
else:
results['locale'][locale] = [label]

options = input_data.get('options')
if options:
# Get each combo of key/value
for key, value in options.items():
if key not in results:
results[key] = {}
if value in results[key]:
results[key][value].append(label)
else:
results[key][value] = [label]

# Try fields in language_names
for key in ['language_label', 'locale_label']:
try:
if input_data.get(key):
value = input_data[key]
if key not in results:
results[key] = {}
if value in results[key]:
results[key][value].append(label)
else:
results[key][value] = [label]
except:
continue

# Try fields in likely_subtags
for key in ['option', 'locale']:
try:
if input_data.get(key):
value = input_data[key]
if key not in results:
results[key] = {}
if value in results[key]:
results[key][value].append(label)
else:
results[key][value] = [label]
except:
continue

for key in ['language_label', 'ignorePunctuation', 'compare_result', 'compare_type', 'test_description']:
try:
if test.get(key): # For collation results
value = test[key]
if key not in results:
results[key] = {}
if value in results[key]:
results[key][value].append(label)
else:
results[key][value] = [label]
except:
continue

for key in ['language_label', 'ignorePunctuation', 'compare_result', 'compare_type', 'test_description']:
if test.get(key): # For collation results
value = test[key]
if key not in results:
Expand All @@ -530,8 +592,6 @@ def characterize_failures_by_options(self, tests, result_type):
results[key][value].append(label)
else:
results[key][value] = [label]
except:
continue

# Look at the input_data part of the test result
# TODO: Check the error_detail and error pars, too.
Expand All @@ -545,21 +605,6 @@ def characterize_failures_by_options(self, tests, result_type):
error_keys = error_detail.keys() # ['options']
self.add_to_results_by_key(label, results, error_detail, test, error_keys)

# if input_data:
# add_to_results_by_key(results, input_data, test, key_list)
# for key in key_list:
# try:
# if (input_data.get(key)): # For collation results
# value = test['input_data'][key]
# if key not in results:
# results[key] = {}
# if value in results[key]:
# results[key][value].append(label)
# else:
# results[key][value] = [label]
# except:
# continue

# TODO: Add substitution of [] for ()
# TODO: Add replacing (...) with "-" for numbers
# TODO: Find the largest intersections of these sets and sort by size
Expand Down

0 comments on commit d819cfa

Please sign in to comment.