-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscp-xxx-j2.html
134 lines (129 loc) · 3.29 KB
/
scp-xxx-j2.html
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<html>
<head>
<meta charset="utf-8">
<script>
'use strict';
var inputs = [
'Your Last Name',
'An Odd Number',
'A Noun',
'A type of Food',
'A Greek Letter',
'Your Favourite TV Show',
'An Adjective',
'An Animal',
'An Even Number',
'Something Cheap (Plural)',
'A Body Part',
'A German Last Name',
'An "-ing" Verb',
'Non-Proper Noun (Plural)',
'Cartoonish Supervillain Goal (i.e. "take over the world")',
'Another Verb',
'Yet Another Verb',
'Your Clearance Level',
'A Profession (Plural)',
'Object Class',
'Small Number Greater than 1',
'A Senior Staff Member',
'American Football Team',
'A Verb and a Noun',
'A Famous Person',
'A Large Number',
'Somewhere Heavily Guarded',
'Another Adjective',
'A Made-Up Town',
'Another "-ing" verb',
'A Noun',
'Another Noun',
'Another Body Part',
'Yet Another Noun (plural)'
];
var grammar = [
'root:{vp}',
'vp:{verb} {noun}|{vpinput}',
'vpinput:{Cartoonish Supervillain Goal (i.e. "take over the world")}|{A Verb and a Noun}',
'vping:{verbing} {noun}',
'np:{article} {noun}|{article} {adjective} {noun}|{propernoun}|{plural}|{adjective} {plural}|{npinput}',
'npinput:{Your Clearance Level}',
'article:a|the|{number}',
'number:{An Odd Number}|{An Even Number}|{Small Number Greater than 1}|{A Large Number}',
'noun:{A Noun}|{Another Noun}|{A type of Food}|{An Animal}|{A Greek Letter}|{A Body Part}|{Another Body Part}|{Object Class}',
'propernoun:{name}|{Your Favourite TV Show}|{place}',
'place:{Somewhere Heavily Guarded}|{A Made-Up Town}',
'name:Dr. {Your Last Name}|Dr. {A German Last Name}|{A Senior Staff Member}|{American Football Team}|{A Famous Person}',
'plural:{Something Cheap (Plural)}|{Non-Proper Noun (Plural)}|{A Profession (Plural)}|{Yet Another Noun (plural)}',
'adjective:{An Adjective}|{Another Adjective}',
'verbing:{An "-ing" Verb}|{Another "-ing" verb}',
'verb:{Another Verb}|{Yet Another Verb}'
];
var lookup = {};
function process_grammar()
{
for (var i = 0; i < inputs.length; i++)
{
var label = '{' + inputs[i] + '}';
lookup[label] = 'INPUT';
}
for (var i = 0; i < grammar.length; i++)
{
var string = grammar[i];
var colon = string.indexOf(':');
var label = '{'+string.substring(0, colon)+'}';
var things = string.substring(colon+1).split('|');
var split_things = [];
for (var j = 0; j < things.length; j++)
{
var regex = /(\{[^}]+\}|[^{]+)/g;
var thing = things[j];
var result;
var split_thing = [];
while ((result = regex.exec(thing)) !== null)
{
var word = result[0];
if (word[0] == '{' && !(word in lookup))
{
lookup[word] = undefined;
}
split_thing.push(result[0]);
}
split_things.push(split_thing);
}
lookup[label] = split_things;
}
for (var label in lookup)
{
if (lookup[label] === undefined)
{
console.log('Undefined label:' + label);
}
}
for (var i = 0; i < inputs.length; i++)
{
var input = '{' + inputs[i] + '}';
var found = false;
for (var label in lookup)
{
if (Array.isArray(lookup[label]))
{
for (var j = 0; j < lookup[label].length; j++)
{
for (var k = 0; k < lookup[label][j].length; k++)
{
found |= (lookup[label][j][k] === input);
}
}
}
}
if (!found)
{
console.log('Unused input: ' + inputs[i]);
}
}
}
window.onload = process_grammar;
</script>
</head>
<body>
</body>
</html>