Add migration scripts

This commit is contained in:
Shaunak Kishore
2015-10-28 23:54:32 -04:00
parent 241d38c23c
commit 32b2f4472d

View File

@ -8,6 +8,44 @@ const checkStrokeExtractorStability = (glyph) => {
} }
} }
const migrateOldGlyphSchemaToNew = (glyph) => {
const codepoint = parseInt(glyph.name.substr(3), 16);
const character = String.fromCodePoint(codepoint);
const data = cjklib.getCharacterData(character);
assert(glyph.manual.verified !== undefined);
const result = {
character: character,
codepoint: codepoint,
metadata: {
definition: undefined,
kangxi_index: data.kangxi_index,
pinyin: undefined,
strokes: undefined,
},
stages: {
path: Glyphs.get_svg_path(glyph),
bridges: glyph.manual.bridges,
strokes: glyph.derived.strokes,
analysis: undefined,
order: undefined,
verified: undefined,
},
};
assert(result.stages.path !== undefined);
assert(result.stages.bridges !== undefined);
assert(result.stages.strokes !== undefined);
return result;
}
const setAnalysisStageToReady = (glyph) => {
const data = cjklib.getCharacterData(glyph.character);
if (data && data.strokes === glyph.stages.strokes.length) {
glyph.stages.analysis = {sentinel: true};
} else {
console.log(`Different stroke count for ${glyph.character}`);
}
}
const completionCallback = undefined; const completionCallback = undefined;
const perGlyphCallback = undefined; const perGlyphCallback = undefined;