Updated batch.js for 10 words
Added import.js to import dictionary Updated license with WordNet info Updated puzzles.js and script for 10 words
This commit is contained in:
@@ -5,13 +5,17 @@ An HTML5 puzzle app, and puzzle file generator. MIT licensed. Code is running at
|
|||||||
Here's a quick rundown of the files:
|
Here's a quick rundown of the files:
|
||||||
|
|
||||||
* app.js - Main logic for the HTML5 GUI
|
* app.js - Main logic for the HTML5 GUI
|
||||||
* batch.js - Node.js batch program which generates a new puzzle.js file containing 1000 puzzles.
|
|
||||||
* flip.manifest_ - unused, but ready to be used for offline Web App
|
* flip.manifest_ - unused, but ready to be used for offline Web App
|
||||||
* index.html - HTML5 page with templates using Underscore templating (ejs).
|
* index.html - HTML5 page with templates using Underscore templating (ejs).
|
||||||
* main.css - style for GUI
|
* main.css - style for GUI
|
||||||
* LICENSE - MIT license for project
|
* LICENSE - MIT license for project
|
||||||
* puzzles.js - generated JSON list of puzzles using batch
|
* puzzles.js - generated JSON list of puzzles using batch
|
||||||
* words.txt - dictionary list of 23,570 words used to generate puzzle.js
|
|
||||||
* fonts/ - offline cache of web fonts used in various formats (included for convenience)
|
* fonts/ - offline cache of web fonts used in various formats (included for convenience)
|
||||||
* lib/ - directory containing third party libraries (included for convenience): backbone, lodash, jquery, normalize.css
|
* lib/ - directory containing third party libraries (included for convenience): backbone, lodash, jquery, normalize.css
|
||||||
* media/ - folder for sound files and images
|
* media/ - folder for sound files and images
|
||||||
|
* utils/ - folder for Node.js scripts which generate dictionary and puzzle files.
|
||||||
|
|
||||||
|
|
||||||
|
WordNet license:
|
||||||
|
|
||||||
|
WordNet Release 3.0 This software and database is being provided to you, the LICENSEE, by Princeton University under the following license. By obtaining, using and/or copying this software and database, you agree that you have read, understood, and will comply with these terms and conditions.: Permission to use, copy, modify and distribute this software and database and its documentation for any purpose and without fee or royalty is hereby granted, provided that you agree to comply with the following copyright notice and statements, including the disclaimer, and that the same appear on ALL copies of the software, database and documentation, including modifications that you make for internal use or for distribution. WordNet 3.0 Copyright 2006 by Princeton University. All rights reserved. THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT- ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. The name of Princeton University or Princeton may not be used in advertising or publicity pertaining to distribution of the software and/or database. Title to copyright in this software, database and any associated documentation shall at all times remain with Princeton University and LICENSEE agrees to preserve same.
|
||||||
@@ -7,6 +7,12 @@ lib/jquery.min.js
|
|||||||
lib/lodash.min.js
|
lib/lodash.min.js
|
||||||
lib/normalize.css
|
lib/normalize.css
|
||||||
main.css
|
main.css
|
||||||
|
fonts/oxygen400.eot
|
||||||
|
fonts/oxygen400.ttf
|
||||||
|
fonts/oxygen400.woff
|
||||||
|
fonts/oxygen700.eot
|
||||||
|
fonts/oxygen700.ttf
|
||||||
|
fonts/oxygen700.woff
|
||||||
media/ding.mp3
|
media/ding.mp3
|
||||||
media/ding.wav
|
media/ding.wav
|
||||||
media/flipscreenshot.png
|
media/flipscreenshot.png
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
for(var i = 0; i < squares.length; i++){
|
for(var i = 0; i < squares.length; i++){
|
||||||
var sq = squares[i]
|
var sq = squares[i]
|
||||||
|
|
||||||
if(i % 4 == 0){
|
if(i % 6 == 0){
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<%
|
<%
|
||||||
@@ -165,5 +165,6 @@ $(function () {
|
|||||||
App.init();
|
App.init();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<a class="forkme" href="https://github.com/russellbeattie/flip"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
16
main.css
16
main.css
@@ -149,7 +149,7 @@ body {
|
|||||||
|
|
||||||
.squares td {
|
.squares td {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 20%;
|
width: 16%;
|
||||||
height: 62px;
|
height: 62px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +278,16 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@media (max-width: 959px) {
|
||||||
|
|
||||||
|
.forkme{
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
|
|
||||||
body{
|
body{
|
||||||
@@ -304,6 +314,10 @@ body {
|
|||||||
height: 38px;
|
height: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.forkme{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
34
utils/README.md
Normal file
34
utils/README.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Utils
|
||||||
|
|
||||||
|
The utils directory contain Node.js Javascript files to create a word dictionary and generate a puzzle.
|
||||||
|
|
||||||
|
* import.js - Imports Princeton's WordNet open dictionary database files into a words.txt file
|
||||||
|
* batch.js - Creates a new puzzle.js file containing 999 word puzzles from the words.txt file created above.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# import.js instructions
|
||||||
|
|
||||||
|
Imports and cleans dictionary files provided by WordNet 3.0
|
||||||
|
|
||||||
|
Download dictionary file (look for "DATABASE FILES ONLY" package):
|
||||||
|
|
||||||
|
http://wordnet.princeton.edu/wordnet/download/current-version/
|
||||||
|
|
||||||
|
Decompress and copy data.adj, data.adv, data.noun and data.verb files
|
||||||
|
to same directory as this script, then run:
|
||||||
|
|
||||||
|
$ node import.js
|
||||||
|
|
||||||
|
This will produce a words.txt dictionary file of 4-10 letter words
|
||||||
|
to be used by batch.js puzzle generator.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# batch.js instructions
|
||||||
|
|
||||||
|
After creating a words.txt dictionary, run:
|
||||||
|
|
||||||
|
$ node batch.js
|
||||||
|
|
||||||
|
This will create a puzzles.js file in the root directory of the project.
|
||||||
@@ -24,11 +24,21 @@ squaresList[4] = [
|
|||||||
{wordlen: 9, squares: [2,2,2,3] },
|
{wordlen: 9, squares: [2,2,2,3] },
|
||||||
{wordlen: 9, squares: [2,2,3,2] },
|
{wordlen: 9, squares: [2,2,3,2] },
|
||||||
{wordlen: 9, squares: [2,3,2,2] },
|
{wordlen: 9, squares: [2,3,2,2] },
|
||||||
{wordlen: 9, squares: [3,2,2,2] }
|
{wordlen: 9, squares: [3,2,2,2] },
|
||||||
|
{wordlen: 10, squares: [3,3,2,2]},
|
||||||
|
{wordlen: 10, squares: [3,2,3,2]},
|
||||||
|
{wordlen: 10, squares: [3,2,2,3]},
|
||||||
|
{wordlen: 10, squares: [2,2,3,3]},
|
||||||
|
{wordlen: 10, squares: [2,3,2,3]}
|
||||||
];
|
];
|
||||||
|
|
||||||
// To fill 20 squares with letters 7 words
|
// To fill 30 squares with
|
||||||
var squaresNeeded = [4, 3, 3, 3, 3, 2, 2];
|
var squaresWordLengths = [
|
||||||
|
[4, 4, 3, 3, 3, 3, 3, 3, 2, 2],
|
||||||
|
[4, 4, 4, 3, 3, 3, 3, 2, 2, 2]
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// pull in the word list, divide into lists by word length
|
// pull in the word list, divide into lists by word length
|
||||||
@@ -52,17 +62,17 @@ for (var i = 0; i < lines.length; i++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// generate puzzles
|
// generate puzzles
|
||||||
var puzzles = [];
|
var puzzles = [];
|
||||||
|
|
||||||
for(var p = 1; p <= 1000; p++){
|
for(var p = 1; p <= 1000; p++){
|
||||||
|
|
||||||
|
|
||||||
var puzzle = {};
|
var puzzle = {};
|
||||||
var cwords = [];
|
var cwords = [];
|
||||||
var csquares = [];
|
var csquares = [];
|
||||||
|
|
||||||
|
var squaresNeeded = squaresWordLengths[Math.floor(Math.random() * squaresWordLengths.length)];
|
||||||
|
|
||||||
for (var i = 0; i < squaresNeeded.length; i++) {
|
for (var i = 0; i < squaresNeeded.length; i++) {
|
||||||
|
|
||||||
var squareTypes = squaresList[squaresNeeded[i]];
|
var squareTypes = squaresList[squaresNeeded[i]];
|
||||||
@@ -107,7 +117,7 @@ var json = JSON.stringify(puzzles);
|
|||||||
|
|
||||||
var js = 'var puzzles = ' + json;
|
var js = 'var puzzles = ' + json;
|
||||||
|
|
||||||
fs.writeFileSync('./puzzles_test.js', js);
|
fs.writeFileSync('../puzzles.js', js);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
122
utils/import.js
Normal file
122
utils/import.js
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
import.js
|
||||||
|
|
||||||
|
Imports and cleans dictionary files provided by WordNet 3.0
|
||||||
|
|
||||||
|
Download dictionary file (look for "DATABASE FILES ONLY" package):
|
||||||
|
|
||||||
|
http://wordnet.princeton.edu/wordnet/download/current-version/
|
||||||
|
|
||||||
|
Decompress and copy data.adj, data.adv, data.noun and data.verb files
|
||||||
|
to same directory as this script, then run:
|
||||||
|
|
||||||
|
$ node import.js
|
||||||
|
|
||||||
|
This will produce a words.txt dictionary file of 4-10 letter words
|
||||||
|
to be used by batch.js puzzle generator.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var files = ['data.adj','data.adv','data.verb','data.noun'];
|
||||||
|
|
||||||
|
var text = '';
|
||||||
|
|
||||||
|
util.log('Starting import');
|
||||||
|
|
||||||
|
for(var f = 0; f < files.length; f++){
|
||||||
|
text += fs.readFileSync('./' + files[f]).toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
var lines = text.split('\n');
|
||||||
|
|
||||||
|
var wordList = [];
|
||||||
|
var defList = [];
|
||||||
|
|
||||||
|
var perc = Math.floor(lines.length / 100);
|
||||||
|
|
||||||
|
for (var i = 0; i < lines.length; i++) {
|
||||||
|
if(lines[i].substr(0, 2) == ' '){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i % perc == 0){
|
||||||
|
util.log(Math.floor((i/lines.length) * 100) + '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
var line = lines[i].trim();
|
||||||
|
var ln = line.split('|');
|
||||||
|
var wordPartStr = ln[0].trim();
|
||||||
|
var wordPart = wordPartStr.split(' ');
|
||||||
|
if(wordPart[4]){
|
||||||
|
var word = wordPart[4].trim();
|
||||||
|
var def = ln[1].trim();
|
||||||
|
|
||||||
|
if(wordList.indexOf(word) !== -1 || word.charAt(0).toUpperCase() == word.charAt(0) || word.indexOf('\'') !== -1 || word.indexOf('-') !== -1 || word.indexOf('_') !== -1 || word.indexOf('(') !== -1){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(def.indexOf(';') !== -1){
|
||||||
|
def = def.substr(0, def.indexOf(';'));
|
||||||
|
}
|
||||||
|
|
||||||
|
def = def.charAt(0).toUpperCase() + def.substr(1) + '.';
|
||||||
|
|
||||||
|
wordList.push(word);
|
||||||
|
defList.push(def);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var words = '';
|
||||||
|
|
||||||
|
for(var x = 4; x < 11; x++){
|
||||||
|
for(var w = 0; w < wordList.length; w++){
|
||||||
|
if(wordList[w].length == x){
|
||||||
|
//console.log(wordList[w] + ' - ' + defList[w]);
|
||||||
|
words += wordList[w] + ' - ' + defList[w] + '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync('./words.txt', words);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
var words = {};
|
||||||
|
|
||||||
|
for(var x = 4; x < 11; x++){
|
||||||
|
var wordList = [];
|
||||||
|
for (var i = 0; i < lines.length; i++) {
|
||||||
|
var line = lines[i].trim();
|
||||||
|
if(line !== ''){
|
||||||
|
var ln = line.split('|');
|
||||||
|
var word = ln[0].trim();
|
||||||
|
var def = ln[1].trim();
|
||||||
|
|
||||||
|
if(wordList.indexOf(word) !== -1){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(def.indexOf(';') !== -1){
|
||||||
|
def = def.substr(0, def.indexOf(';'));
|
||||||
|
}
|
||||||
|
|
||||||
|
def = def.charAt(0).toUpperCase() + def.substr(1) + '.';
|
||||||
|
var s = word.length;
|
||||||
|
|
||||||
|
if(s == x){
|
||||||
|
wordList.push(word);
|
||||||
|
console.log(word + ' - ' + def);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
33505
utils/words.txt
Normal file
33505
utils/words.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user