This commit is contained in:
Akbar Rahman 2022-09-12 14:00:06 +01:00
parent 32e976a021
commit 4161293d31
Signed by: alvierahman90
GPG Key ID: 20609519444A1269
7 changed files with 11 additions and 794854 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +0,0 @@
adj
prep
adv
num
int
verb
pron
conj
noc
@

View File

@ -1,5 +1,5 @@
// global constants // global constants
const gridWidth = 5 const gridWidth = 6
const gridHeight = 6 const gridHeight = 6
const word = wordlist[Math.floor(Math.random()*wordlist.length)]; const word = wordlist[Math.floor(Math.random()*wordlist.length)];
@ -191,16 +191,21 @@ function runClickAnimation(el) {
el.classList.add("clicked") el.classList.add("clicked")
setTimeout(() => el.classList.remove("clicked"), 500) setTimeout(() => el.classList.remove("clicked"), 500)
} }
// create event listeners // create event listeners
document.addEventListener('keyup', e => setNextLetter(e)) document.addEventListener('keyup', e => setNextLetter(e))
kbBackspace.addEventListener('click', () => { kbBackspace.addEventListener('click', () => {
runClickAnimation(kbBackspace) runClickAnimation(kbBackspace)
setNextLetter({code: "Backspace", key: "Backspace"}) setNextLetter({code: "Backspace", key: "Backspace"})
}) })
kbEnter.addEventListener('click', () => { kbEnter.addEventListener('click', () => {
runClickAnimation(kbEnter) runClickAnimation(kbEnter)
setNextLetter({code: "Enter", key: "Enter"}) setNextLetter({code: "Enter", key: "Enter"})
}) })
kbLetters.forEach(kbl => { kbLetters.forEach(kbl => {
kbl.addEventListener('click', () => { kbl.addEventListener('click', () => {
runClickAnimation(kbl) runClickAnimation(kbl)
@ -208,6 +213,7 @@ kbLetters.forEach(kbl => {
}) })
}) })
// start game // start game
init() init()
console.log(word) console.log(word)

View File

@ -4,10 +4,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="styles.css"> <link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" type="text/css" href="./Font-Awesome/css/all.min.css"> <link rel="stylesheet" type="text/css" href="./Font-Awesome/css/all.min.css">
<title>words by alv</title> <title>shalomle</title>
</head> </head>
<body> <body>
<h1 style="text-align: center">words by alv</h1> <h1 style="text-align: center">shalomle</h1>
<div id="game_container"> <div id="game_container">
</div> </div>

View File

@ -1,8 +1,2 @@
# words # shalomle
you know what it is
wordlist `1_1_all_fullalpha.txt` is from Lancaster University, available [here](https://ucrel.lancs.ac.uk/bncfreq/flists.html)
![screenshot](./screenshot.png)

View File

@ -1,63 +0,0 @@
#!/usr/bin/env python3
import sys
import json
class WordListItem:
def __init__(self, line):
word = line.split('\t')
self.word = word[1] if word[1].isalpha() else word[3]
self.pos = word[2]
self.frequency = int(word[4])
def __repr__(self):
return f"<WordListItem {self.word=} {self.pos=} {self.frequency=}>"
def get_args():
""" Get command line arguments """
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('wordlist')
parser.add_argument('word_length', type=int)
parser.add_argument('frequency_min', type=int)
parser.add_argument('allowedtypelist')
return parser.parse_args()
def main(args):
""" Entry point for script """
with open(args.allowedtypelist) as fp:
allowed_types = fp.read().split('\n')
types = set()
with open(args.wordlist) as fp:
words = [ WordListItem(line) for line in fp.read().strip().lower().split('\n') ]
[ types.add(word.pos) for word in words ]
words = [ word.word for word in words if word.frequency >= args.frequency_min and word.word.isalpha() and len(word.word) == args.word_length and word.pos in allowed_types ]
words.sort()
# remove duplicates
words = list(set(words))
print(f"wordlist = {json.dumps(words)}")
print(f"{args=}", file=sys.stderr)
print(f"{len(words)=}", file=sys.stderr)
print(f"{types=}", file=sys.stderr)
print(f"{'cares' in words=}", file=sys.stderr)
print(f"{'ideas' in words=}", file=sys.stderr)
print(f"{'prose' in words=}", file=sys.stderr)
return 0
if __name__ == '__main__':
try:
sys.exit(main(get_args()))
except KeyboardInterrupt:
sys.exit(0)

1
wordlist.js Normal file
View File

@ -0,0 +1 @@
wordlist = [ "shalom" ]