File size: 1,026 Bytes
f91a684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import fs from 'fs';

const content = fs.readFileSync('src/components/AptitudeContentPage.tsx', 'utf-8');
const parseFuncMatch = content.match(/function parseAptitudeContent[\s\S]*?return questions;\n}/);
if (parseFuncMatch) {
  let code = parseFuncMatch[0].replace(/export /g, '');
  // strip types
  code = code.replace(/: ParsedQuestion\[\]/g, '');
  code = code.replace(/: string/g, '');
  code = code.replace(/as any/g, '');
  
  const fs = require('fs');
  fs.writeFileSync('temp.js', `
  function formatPassageTables(text) { return text; }
  ${code}
  
  const testText = \`Q1. What were the total sales in 2020?
Statement 1: Q3 sales in 2020 were ₹35 lakhs.
Statement 2: Total sales in 2021 were ₹140 lakhs.
A) Statement 1 alone   B) Statement 2 alone   C) Both together   D) Either alone   E) Neither
Answer: A) Statement 1 alone
Explanation: 2020 total = 25+30+Q3+20. With Q3=35 → total=110. St1 alone sufficient. Answer A.\`;
  
  console.log(JSON.stringify(parseAptitudeContent(testText), null, 2));
  `);
}