Quest 6: Creating a list of known words

//version 2
const wordsKnown = [];
commands.forEach(cmd => {
  cmd.regexes.forEach(rgx => {
    //console.log(rgx.source)
    let regexP = /\w+/g;
    const result = [...rgx.source.matchAll(regexP)]
    //console.log(result)
    result.forEach(word => {
      if (!wordsKnown.includes(word[0])){
        wordsKnown.push(word[0]);
        wordsKnown.sort(Intl.Collator().compare); //updated this line to perform non case-sensitive sort
      }
    })
  })
})

QuestJS has 225 words in its command patterns.

[0…99]
​0: "about"
​​
1: "active"
​​
2: "again"
​​
3: "anti"
​​
4: "anticlockwise"
​​
5: "ask"
​​
6: "at"
​​
7: "attach"
​​
8: "back"
​​
9: "behind"
​​
10: "break"
​​
11: "brief"
​​
12: "burst"
​​
13: "buy"
​​
14: "check"
​​
15: "chug"
​​
16: "clear"
​​
17: "clockwise"
​​
18: "close"
​​
19: "clue"
​​
20: "consume"
​​
21: "converse"
​​
22: "credits"
​​
23: "d"
​​
24: "dark"
​​
25: "deactivate"
​​
26: "decant"
​​
27: "del"
​​
28: "delete"
​​
29: "destroy"
​​
30: "detach"
​​
31: "dine"
​​
32: "dir"
​​
33: "directory"
​​
34: "disable"
​​
35: "discharge"
​​
36: "dn"
​​
37: "doff"
​​
38: "don"
​​
39: "down"
​​
40: "drag"
​​
41: "drink"
​​
42: "drop"
​​
43: "e"
​​
44: "east"
​​
45: "eat"
​​
46: "empty"
​​
47: "enable"
​​
48: "enter"
​​
49: "ex"
​​
50: "exam"
​​
51: "examine"
​​
52: "exit"
​​
53: "exits"
​​
54: "fasten"
​​
55: "feed"
​​
56: "fill"
​​
57: "follow"
​​
58: "following"
​​
59: "font"
​​
60: "fonts"
​​
61: "for"
​​
62: "frm"
​​
63: "from"
​​
64: "g"
​​
65: "get"
​​
66: "give"
​​
67: "go"
​​
68: "goto"
​​
69: "grab"
​​
70: "guzzle"
​​
71: "head"
​​
72: "help"
​​
73: "her"
​​
74: "here"
​​
75: "hint"
​​
76: "his"
​​
77: "holler"
​​
78: "how"
​​
79: "i"
​​
80: "imbibe"
​​
81: "in"
​​
82: "info"
​​
83: "ing"
​​
84: "ingest"
​​
85: "ings"
​​
86: "insert"
​​
87: "inside"
​​
88: "into"
​​
89: "intro"
​​
90: "inv"
​​
91: "inventory"
​​
92: "knock"
​​
93: "l"
​​
94: "left"
​​
95: "lie"
​​
96: "listen"
​​
97: "load"
​​
98: "lock"
​​
99: "look"
[100…199]
​​
100: "ls"
​​
101: "map"
​​
102: "me"
​​
103: "mode"
​​
104: "move"
​​
105: "my"
​​
106: "n"
​​
107: "ne"
​​
108: "north"
​​
109: "northeast"
​​
110: "northwest"
​​
111: "nw"
​​
112: "o"
​​
113: "of"
​​
114: "off"
​​
115: "offer"
​​
116: "on"
​​
117: "onto"
​​
118: "oops"
​​
119: "open"
​​
120: "out"
​​
121: "overwrite"
​​
122: "ow"
​​
123: "partake"
​​
124: "peek"
​​
125: "peer"
​​
126: "pick"
​​
127: "pierce"
​​
128: "place"
​​
129: "plain"
​​
130: "pour"
​​
131: "press"
​​
132: "proffer"
​​
133: "pronouns"
​​
134: "pull"
​​
135: "puncture"
​​
136: "purchase"
​​
137: "push"
​​
138: "put"
​​
139: "quaff"
​​
140: "r"
​​
141: "read"
​​
142: "recline"
​​
143: "reload"
​​
144: "remove"
​​
145: "restart"
​​
146: "restore"
​​
147: "right"
​​
148: "rotate"
​​
149: "s"
​​
150: "save"
​​
151: "say"
​​
152: "scoop"
​​
153: "score"
​​
154: "scream"
​​
155: "script"
​​
156: "se"
​​
157: "search"
​​
158: "sell"
​​
159: "sh"
​​
160: "shift"
​​
161: "shout"
​​
162: "show"
​​
163: "silent"
​​
164: "sip"
​​
165: "sit"
​​
166: "smash"
​​
167: "smell"
​​
168: "sniff"
​​
169: "south"
​​
170: "southeast"
​​
171: "southwest"
​​
172: "speak"
​​
173: "spoken"
​​
174: "stand"
​​
175: "stop"
​​
176: "sw"
​​
177: "swallow"
​​
178: "swig"
​​
179: "swill"
​​
180: "switch"
​​
181: "t"
​​
182: "take"
​​
183: "talk"
​​
184: "tell"
​​
185: "terse"
​​
186: "through"
​​
187: "tie"
​​
188: "to"
​​
189: "toggle"
​​
190: "topics"
​​
191: "transcript"
​​
192: "turn"
​​
193: "twist"
​​
194: "u"
​​
195: "under"
​​
196: "undo"
​​
197: "unfasten"
​​
198: "unlock"
​​
199: "untie"
​
[200…224]
​​
200: "up"
​​
201: "upon"
​​
202: "use"
​​
203: "verbose"
​​
204: "version"
​​
205: "w"
​​
206: "wait"
​​
207: "walk"
​​
208: "walkthrough"
​​
209: "warn"
​​
210: "wear"
​​
211: "west"
​​
212: "what"
​​
213: "when"
​​
214: "where"
​​
215: "whisper"
​​
216: "who"
​​
217: "why"
​​
218: "widdershins"
​​
219: "with"
​​
220: "wt"
​​
221: "x"
​​
222: "yell"
​​
223: "your"
​​
224: "z"
​
length: 225

I don't know what to do with that (if anything), but I'm posting it here so I can't lose it.


PS

I just learned the word "widdershins". So, I got at least one thing out of this. :)


const pronounsKnown = [];
Object.values(lang.pronouns).forEach(val => {
  Object.values(val).forEach(v => {
    if (!pronounsKnown.includes(v)){
      pronounsKnown.push(v)
    }
  })
})
pronounsKnown.sort(Intl.Collator().compare);

Now we have a list of known pronouns.


EDIT

Okay, now it finds all the words in all the patterns, the pronouns, the object aliases, and any object regex attributes. Plus, it adds the articles.

const articlesKnown = ["a", "an", "some", "the"];

const nounsKnown = [];
Object.keys(w).forEach(key => {
  let regexen = [];
  nounsKnown.push(w[key].alias)
  if (w.regex){
    let regexP = /\w+/g;
    w.regex.forEach(rgx => {
        const result = [...rgx.source.matchAll(regexP)]
        //console.log(result)
        result.forEach(word => {
            if (!nounsKnown.includes(word[0])){
                nounsKnown.push(word[0]);
            }
        })
    })
  }
})
nounsKnown.sort(Intl.Collator().compare)

const wordsKnown = [];
commands.forEach(cmd => {
  cmd.regexes.forEach(rgx => {
    //console.log(rgx.source)
    let regexP = /\w+/g;
    const result = [...rgx.source.matchAll(regexP)]
    //console.log(result)
    result.forEach(word => {
      if (!wordsKnown.includes(word[0])){
        wordsKnown.push(word[0]);
      }
    })
  })
})
wordsKnown.sort(Intl.Collator().compare); //updated this line to perform non case-sensitive sort


const pronounsKnown = [];
Object.values(lang.pronouns).forEach(val => {
  Object.values(val).forEach(v => {
    if (!pronounsKnown.includes(v)){
      pronounsKnown.push(v)
    }
  })
})
pronounsKnown.sort(Intl.Collator().compare);

const funkAndWagnalls = [...nounsKnown, ...pronounsKnown, ...wordsKnown, ...articlesKnown];

funkAndWagnalls.sort(Intl.Collator().compare);

funkAndWagnalls

[0…99]
​​
0: "a"
​​
1: "about"
​​
2: "active"
​​
3: "again"
​​
4: "an"
​​
5: "anti"
​​
6: "anticlockwise"
​​
7: "ask"
​​
8: "at"
​​
9: "attach"
​​
10: "back"
​​
11: "behind"
​​
12: "break"
​​
13: "brief"
​​
14: "burst"
​​
15: "buy"
​​
16: "check"
​​
17: "chug"
​​
18: "clear"
​​
19: "clockwise"
​​
20: "close"
​​
21: "clue"
​​
22: "consume"
​​
23: "converse"
​​
24: "credits"
​​
25: "d"
​​
26: "dark"
​​
27: "deactivate"
​​
28: "decant"
​​
29: "del"
​​
30: "delete"
​​
31: "destroy"
​​
32: "detach"
​​
33: "dine"
​​
34: "dir"
​​
35: "directory"
​​
36: "disable"
​​
37: "discharge"
​​
38: "dn"
​​
39: "doff"
​​
40: "don"
​​
41: "down"
​​
42: "drag"
​​
43: "drink"
​​
44: "drop"
​​
45: "e"
​​
46: "east"
​​
47: "eat"
​​
48: "empty"
​​
49: "enable"
​​
50: "enter"
​​
51: "ex"
​​
52: "exam"
​​
53: "examine"
​​
54: "exit"
​​
55: "exits"
​​
56: "fasten"
​​
57: "feed"
​​
58: "fill"
​​
59: "follow"
​​
60: "following"
​​
61: "font"
​​
62: "fonts"
​​
63: "for"
​​
64: "frm"
​​
65: "from"
​​
66: "g"
​​
67: "get"
​​
68: "give"
​​
69: "go"
​​
70: "goto"
​​
71: "grab"
​​
72: "guzzle"
​​
73: "he"
​​
74: "head"
​​
75: "help"
​​
76: "her"
​​
77: "her"
​​
78: "here"
​​
79: "hers"
​​
80: "herself"
​​
81: "him"
​​
82: "himself"
​​
83: "hint"
​​
84: "his"
​​
85: "his"
​​
86: "holler"
​​
87: "how"
​​
88: "i"
​​
89: "I"
​​
90: "imbibe"
​​
91: "in"
​​
92: "info"
​​
93: "ing"
​​
94: "ingest"
​​
95: "ings"
​​
96: "insert"
​​
97: "inside"
​​
98: "into"
​​
99: "intro"
​
[100…199]
​​
100: "inv"
​​
101: "inventory"
​​
102: "it"
​​
103: "its"
​​
104: "itself"
​​
105: "knock"
​​
106: "l"
​​
107: "left"
​​
108: "lie"
​​
109: "listen"
​​
110: "load"
​​
111: "lock"
​​
112: "look"
​​
113: "lounge"
​​
114: "ls"
​​
115: "map"
​​
116: "me"
​​
117: "me"
​​
118: "me"
​​
119: "mine"
​​
120: "mode"
​​
121: "move"
​​
122: "my"
​​
123: "my"
​​
124: "myself"
​​
125: "n"
​​
126: "ne"
​​
127: "north"
​​
128: "northeast"
​​
129: "northwest"
​​
130: "nw"
​​
131: "o"
​​
132: "of"
​​
133: "off"
​​
134: "offer"
​​
135: "on"
​​
136: "onto"
​​
137: "oops"
​​
138: "open"
​​
139: "out"
​​
140: "overwrite"
​​
141: "ow"
​​
142: "partake"
​​
143: "peek"
​​
144: "peer"
​​
145: "pick"
​​
146: "pierce"
​​
147: "place"
​​
148: "plain"
​​
149: "pour"
​​
150: "press"
​​
151: "proffer"
​​
152: "pronouns"
​​
153: "pull"
​​
154: "puncture"
​​
155: "purchase"
​​
156: "push"
​​
157: "put"
​​
158: "quaff"
​​
159: "r"
​​
160: "read"
​​
161: "recline"
​​
162: "reload"
​​
163: "remove"
​​
164: "restart"
​​
165: "restore"
​​
166: "right"
​​
167: "rotate"
​​
168: "s"
​​
169: "save"
​​
170: "say"
​​
171: "scoop"
​​
172: "score"
​​
173: "scream"
​​
174: "script"
​​
175: "se"
​​
176: "search"
​​
177: "sell"
​​
178: "sh"
​​
179: "she"
​​
180: "shift"
​​
181: "shout"
​​
182: "show"
​​
183: "silent"
​​
184: "sip"
​​
185: "sit"
​​
186: "smash"
​​
187: "smell"
​​
188: "sniff"
​​
189: "some"
​​
190: "south"
​​
191: "southeast"
​​
192: "southwest"
​​
193: "speak"
​​
194: "spoken"
​​
195: "stand"
​​
196: "stop"
​​
197: "sw"
​​
198: "swallow"
​​
199: "swig"
​
[200…255]
​​
200: "swill"
​​
201: "switch"
​​
202: "t"
​​
203: "take"
​​
204: "talk"
​​
205: "tell"
​​
206: "terse"
​​
207: "the"
​​
208: "their"
​​
209: "theirs"
​​
210: "them"
​​
211: "themselves"
​​
212: "they"
​​
213: "through"
​​
214: "tie"
​​
215: "to"
​​
216: "toggle"
​​
217: "topics"
​​
218: "transcript"
​​
219: "turn"
​​
220: "twist"
​​
221: "u"
​​
222: "under"
​​
223: "undo"
​​
224: "unfasten"
​​
225: "unlock"
​​
226: "untie"
​​
227: "up"
​​
228: "upon"
​​
229: "use"
​​
230: "verbose"
​​
231: "version"
​​
232: "w"
​​
233: "wait"
​​
234: "walk"
​​
235: "walkthrough"
​​
236: "warn"
​​
237: "wear"
​​
238: "west"
​​
239: "what"
​​
240: "when"
​​
241: "where"
​​
242: "whisper"
​​
243: "who"
​​
244: "why"
​​
245: "widdershins"
​​
246: "with"
​​
247: "wt"
​​
248: "x"
​​
249: "yell"
​​
250: "you"
​​
251: "your"
​​
252: "your"
​​
253: "yours"
​​
254: "yourself"
​​
255: "z"
​
length: 256


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums