-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.js
76 lines (65 loc) · 2.36 KB
/
debug.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
/* eslint-disable */
const complex = require("./debugComplex");
const grammar = require("./grammar");
const { story } = require("./grammar/stories/");
let macros = require("./grammar/macros");
var argv = require("minimist")(process.argv.slice(2));
// console.dir(argv);
// console.log("Story:", story);
const templateWithoutReply = "#initialStory#\n";
const templateForceText = "After #takesTime#, #instructing#\n";
const templateForceReply = "#[deityName:Waï-ceizsteuach]replyWithDeity#\n";
let template = argv.template || "#origin#\n\n\n";
// template = complex; // uncomment to use template from separate file debugComplex.js
// template = templateForceText; // uncomment to force the above template
template = templateForceReply; // uncomment to force the above reply template
// template = templateWithoutReply; // uncomment to force the above reply template
// template = "#dwelling#"; // insert manual template here
// Checks to perform:
// Search code for [^a-zA-Z]#(\w|\.)+[^#][, ] to find unmatched #words#
// Search output for (( and )) and .. and ,. and ,.
// Check how many of the output samples are over maximum number of characters
// (this is listed at the end of the debug output)
const COUNT = argv.count || 123;
macros +=
"#setDeity##setCharacter#" +
// "[deityName:Süüm-yüüng-dei'ï'ðéé]" +
// "[deityDomain:Voodoo]" +
// "[deityType:deity]" +
// "[deityPlace:in Sheffield]" +
// "[spiritAnimal:hooded crow]" +
"[userHandle:@dansumption]" +
// "[deityThey:she][deityThem:her][deityTheir:her][deityTheirs:hers]";
"";
const TweetLength = argv.max || 259;
let tooLong = [];
const getPhrase = () => {
const phrase = grammar.flatten(macros + template);
console.log(phrase);
if (phrase.length > TweetLength) {
tooLong.push(phrase);
}
};
const listPhrases = () => {
for (let index = 0; index < COUNT; index++) {
getPhrase();
}
};
if (argv._.find(val => val === "stories")) {
story.forEach(scenario => {
template = scenario;
listPhrases();
console.log("\n---\n\n");
});
} else {
// grammar.debug();
listPhrases();
}
console.log(
"\nLONGEST:\n\n" +
tooLong
.sort((a, b) => a.length - b.length)
.map(phrase => `${phrase.length}: ${phrase}`)
.join("\n\n"),
`That makes ${tooLong.length} out of ${COUNT} possible tweets`
);