MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / extractInputs

Function extractInputs

benchmarks/wester/extract.mjs:73–103  ·  view source on GitHub ↗
(transcript, sourceUrl)

Source from the content-addressed store, hash-verified

71}
72
73function extractInputs(transcript, sourceUrl) {
74 const lines = transcript.replaceAll('\r\n', '\n').split('\n');
75 const expressions = [];
76
77 for (let index = 0; index < lines.length; index += 1) {
78 const start = lines[index].match(/^In\[\d+\]:=\s?(.*)$/);
79 if (!start) continue;
80 if (start[1].trim() === '') continue;
81 if (start[1].trim() === 'Quit[]') continue;
82
83 const input = [start[1]];
84 while (
85 index + 1 < lines.length &&
86 !isTiming(lines[index + 1]) &&
87 !isSessionBoundary(lines[index + 1])
88 ) {
89 input.push(lines[index + 1]);
90 index += 1;
91 }
92
93 const expression = repairTerminalWrapping(input).join('\n').trim();
94 if (expression) expressions.push(expression);
95 }
96
97 return [
98 `(* Extracted from ${sourceUrl}`,
99 ` Source index: ${INDEX_URL} *)`,
100 '',
101 ...expressions.flatMap((expression) => [expression, '']),
102 ].join('\n');
103}
104
105const indexResponse = await fetch(INDEX_URL);
106if (!indexResponse.ok) {

Callers 1

extract.mjsFile · 0.85

Calls 4

isTimingFunction · 0.85
isSessionBoundaryFunction · 0.85
repairTerminalWrappingFunction · 0.85
matchMethod · 0.65

Tested by

no test coverage detected