-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconvert.js
81 lines (69 loc) · 3.09 KB
/
convert.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const _ = require("lodash");
const fs = require("fs");
const slugify = require("slugify");
const glob = require("glob");
// Load all the local gpt3 outputs for "resumes"
const gpt3Output = glob.sync("./gpt3-output/*.txt");
_.each(gpt3Output, (outputPath) => {
// Read gpt3 output from file
const output = fs.readFileSync(outputPath, "utf8");
// Convert gpt3 output into object
const outputObject = {};
_.each(output.split("\n"), (line) => {
const keyValue = line.split(":");
outputObject[keyValue[0]] = keyValue[1];
});
console.log(outputObject);
// Load the template resume.json we will inject values into
const resumeTemplate = JSON.parse(fs.readFileSync("./resume.json"));
// Replace resume.json template values with gpt3 object values
resumeTemplate.basics.name = outputObject.Name;
resumeTemplate.basics.email =
slugify(outputObject.Name).toLowerCase() + "@gmail.com";
resumeTemplate.basics.label = outputObject["Job Title"];
resumeTemplate.basics.summary = outputObject["Summary"];
resumeTemplate.work[0].company = outputObject["Company #1 Name"];
resumeTemplate.work[0].summary = outputObject["Company #1 Summary"];
resumeTemplate.work[0].position = outputObject["Company #1 Role"];
resumeTemplate.work[0].website =
"https://" +
slugify(outputObject["Company #1 Name"].toLowerCase()) +
".com";
resumeTemplate.work[0].highlights[0] = outputObject["Company #1 Highlight 1"];
resumeTemplate.work[0].highlights[1] = outputObject["Company #1 Highlight 2"];
resumeTemplate.work[1].company = outputObject["Company #2 Name"];
resumeTemplate.work[1].summary = outputObject["Company #2 Summary"];
resumeTemplate.work[1].position = outputObject["Company #2 Role"];
resumeTemplate.work[1].website =
"https://" +
slugify(outputObject["Company #1 Name"].toLowerCase()) +
".com";
resumeTemplate.work[1].highlights[0] = outputObject["Company #2 Highlight 1"];
resumeTemplate.work[1].highlights[1] = outputObject["Company #2 Highlight 2"];
resumeTemplate.interests = [];
// Replace , with . because gpt3 gets a bit creative with grammar
const outputInterests = outputObject["Interests"]
.replace(",", ".")
.split(".");
_.each(outputInterests, (interest) => {
resumeTemplate.interests.push({ name: interest });
});
// "work": [
// {
// "highlights": [
// "Millions of sites use the CDN in production",
// "Millions of sites use the CDN in production"
// ],
// "summary": "Following Google’s CDN for jQuery, we decided to start a CDN for the less popular Javascript frameworks. The CDN is community moderated and open source on GitHub. We secured a partnership with Cloudflare who now supports the infrastructure.",
// "website": "http://www.cdnjs.com",
// "company": "Cdnjs",
// "position": "Co-Founder",
// "startDate": "2018-01-08",
// "endDate": "2020-09-08"
// },
resumeTemplate.references[0].reference = outputObject["Personal Reference"];
fs.writeFileSync(
"./resumes/" + slugify(outputObject.Name) + ".json",
JSON.stringify(resumeTemplate, undefined, 4)
);
});