mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-11-01 12:07:15 +08:00
Add complete failure of a trained classifier
This commit is contained in:
@ -494,7 +494,7 @@ function extract_strokes(paths, endpoints, bridges, log) {
|
||||
|
||||
// Exports go below this fold.
|
||||
|
||||
this.get_glyph_render_data = function(glyph, manual_bridges) {
|
||||
this.get_glyph_render_data = function(glyph, manual_bridges, classifier) {
|
||||
var paths = orient_paths(split_path(glyph.path));
|
||||
var endpoints = [];
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
@ -503,7 +503,7 @@ this.get_glyph_render_data = function(glyph, manual_bridges) {
|
||||
}
|
||||
}
|
||||
var log = [];
|
||||
var bridges = get_bridges(endpoints, hand_tuned_classifier);
|
||||
var bridges = get_bridges(endpoints, classifier || hand_tuned_classifier);
|
||||
var strokes = extract_strokes(
|
||||
paths, endpoints, manual_bridges || bridges, log);
|
||||
var expected = UNIHAN_STROKE_COUNTS[glyph.name];
|
||||
@ -524,6 +524,20 @@ this.get_glyph_render_data = function(glyph, manual_bridges) {
|
||||
};
|
||||
}
|
||||
|
||||
this.check_classifier_on_glyph = function(glyph, classifier) {
|
||||
assert(glyph.manual.verified);
|
||||
var render = get_glyph_render_data(glyph, undefined, classifier);
|
||||
function canonicalize(bridges) {
|
||||
var result = [];
|
||||
for (var i = 0; i < bridges.length; i++) {
|
||||
result.push(Point.key(bridges[i].map(Point.key).sort()));
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
return _.isEqual(canonicalize(render.bridges),
|
||||
canonicalize(glyph.manual.bridges));
|
||||
}
|
||||
|
||||
this.get_glyph_training_data = function(glyph) {
|
||||
assert(glyph.manual.verified);
|
||||
var paths = orient_paths(split_path(glyph.path));
|
||||
@ -570,3 +584,5 @@ this.get_glyph_training_data = function(glyph) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
this.hand_tuned_classifier = hand_tuned_classifier;
|
||||
|
||||
Reference in New Issue
Block a user