| 60 | |
| 61 | // Function to update parser files |
| 62 | function updateParserFiles(popularityData, parsersDir) { |
| 63 | const files = fs.readdirSync(parsersDir) |
| 64 | for (let file of files) { |
| 65 | if (file.endsWith(".parsers")) { |
| 66 | const filePath = path.join(parsersDir, file) |
| 67 | let content = fs.readFileSync(filePath, "utf-8") |
| 68 | const lines = content.split("\n") |
| 69 | const updatedLines = [] |
| 70 | for (let line of lines) { |
| 71 | updatedLines.push(line) |
| 72 | for (let parserId in popularityData) { |
| 73 | if (line.startsWith(parserId)) { |
| 74 | updatedLines.push(` popularity ${popularityData[parserId].toFixed(6)}`) |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | fs.writeFileSync(filePath, updatedLines.join("\n")) |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Main function |
| 84 | function main(csvFilePaths, parsersDir) { |