Skip to content

Commit

Permalink
update randomRhymes
Browse files Browse the repository at this point in the history
  • Loading branch information
cqx931 committed Aug 13, 2020
1 parent 392901b commit 7f2f73f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions examples/dom/RandomRhymes/code.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
$(document).ready(function () {

//initialize lexicon
var lexicon = new RiLexicon();
const lexicon = RiTa.lexicon();

findRhymes();
setInterval(findRhymes, 2000); // called every 2 sec by timer

function findRhymes() {

var word, tmp = '';
let word, tmp = '';
do {
word = lexicon.randomWord();
tmp = lexicon.rhymes(word);
} while ( word && tmp.length < 3)

var rhymes = tmp.slice(0, Math.min(tmp.length, 13));
const rhymes = tmp.slice(0, Math.min(tmp.length, 13));

$('#word').html(word);
$('#rhyme').html(rhymes.join("<br>"));
Expand Down
2 changes: 1 addition & 1 deletion examples/dom/RandomRhymes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>RandomRhymes (dom)</title>
<meta charset="utf-8">
<script src="../../../lib/rita-web.js"></script>
<script src="../../lib/jquery-1.12.4.js"></script>
<script src="../../lib/jquery-3.5.1.min.js"></script>
<script src="code.js"></script>
<script src="../../lib/prism.js"></script>
<script src="../../lib/sourcecode.js"></script>
Expand Down
10 changes: 5 additions & 5 deletions examples/p5/RandomRhymes/code.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

var rhymes, word;
let rhymes, word;

function setup()
{
createCanvas(300, 300);
fill(255);
textFont("Georgia");

lexicon = new RiLexicon();
lexicon = RiTa.lexicon();
findRhymes();

setInterval(findRhymes, 2000);
Expand All @@ -29,12 +29,12 @@ function draw()

function findRhymes() { // called by timer

var tmp = '';
let tmp = '';
do {
word = lexicon.randomWord();
tmp = lexicon.rhymes(word);
} while ( word && tmp.length < 3)
} while ( word && tmp.length < 3)

var arr = subset(tmp, 0, min(tmp.length, 13)); // max of 13 words
const arr = subset(tmp, 0, min(tmp.length, 13)); // max of 13 words
rhymes = arr.join("\n");
}
2 changes: 1 addition & 1 deletion examples/p5/RandomRhymes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script src="../../lib/p5.min.js"></script>
<script src="../../../lib/rita-web.js"></script>
<script src="code.js"></script>
<script src="../../lib/jquery-1.12.4.js"></script>
<script src="../../lib/jquery-3.5.1.min.js"></script>
<script src="../../lib/prism.js"></script>
<script src="../../lib/sourcecode.js"></script>
<link rel='stylesheet' href='../../lib/prism.css' />
Expand Down

0 comments on commit 7f2f73f

Please sign in to comment.