bugfix: make parsing more robust
Now it parses output from ChatGPT :P
This commit is contained in:
parent
ae595b45e6
commit
65b18cc1f0
3 changed files with 12 additions and 7 deletions
|
@ -13,7 +13,6 @@ function do_visualisation(el_in, el_out) {
|
|||
console.log(summary);
|
||||
|
||||
const svg = make_graph(summary);
|
||||
console.log(svg);
|
||||
|
||||
const container = document.createElement("div");
|
||||
container.innerHTML = svg;
|
||||
|
|
|
@ -81,7 +81,10 @@ function make_context() {
|
|||
{
|
||||
name: "copy-html",
|
||||
setup(build) {
|
||||
build.onEnd(_result => {
|
||||
build.onEnd(result => {
|
||||
if (result.errors.length > 0 || result.warnings.length > 0)
|
||||
console.log(result);
|
||||
console.log(`${new Date().toISOString()} | Build complete`);
|
||||
do_html();
|
||||
})
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@ export default function parse_summary(text) {
|
|||
const sep_output_shape = lines[2].search("Output Shape");
|
||||
const sep_param_hash = lines[2].search("Param #");
|
||||
const sep_connected_to = has_connected_to ? lines[2].search("Connected to") : lines[2].length;
|
||||
|
||||
console.log(`DEBUG:layers_raw`, layers_raw);
|
||||
let layer_prev = null;
|
||||
let acc = [];
|
||||
for (const line of layers_raw) {
|
||||
if(line.trim().length == 0) {
|
||||
console.log(`DEBUG:layers/line`, line, `CONDITION B`, line.trim().search(/^\-+$/));
|
||||
if(line.trim().length == 0 || line.trim().search(/^[-_]+$/) > -1) {
|
||||
if(acc.length === 0) continue;
|
||||
console.log(`LAYER`);
|
||||
|
||||
console.log(`DEBUG:params`, acc.map(layer_line => layer_line.substring(sep_param_hash, sep_connected_to).trim()));
|
||||
// Handle parsed item
|
||||
|
@ -39,7 +41,8 @@ export default function parse_summary(text) {
|
|||
result.connected_to = [ layer_prev.name ];
|
||||
}
|
||||
|
||||
result.type = result.name_raw.match(/ \(([^)]+)\)/)[1];
|
||||
console.log(`DEBUG:result`, result)
|
||||
result.type = result.name_raw.match(/ \(([^)]+)(?:\)|$)/)[1];
|
||||
result.name = result.name_raw.split(/\s+/)[0];
|
||||
|
||||
layer_prev = result;
|
||||
|
@ -47,7 +50,7 @@ export default function parse_summary(text) {
|
|||
|
||||
acc.length = 0;
|
||||
}
|
||||
|
||||
else
|
||||
acc.push(line);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue