-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyn.js
53 lines (46 loc) · 1.14 KB
/
syn.js
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
var link = "http://words.bighugelabs.com/api/2/663fff93648e4bbfc4bc4a79c1371b44/";
var samplelist = ["abase","abash","abate","abattoir","abdicate","aberration","abet","abeyance","abhor","abject"]
$(document).ready(function() {
convertDIC();
//getWSL('nice');
});
var getWSL = function(QUERY, cb){
var WSL = new Array();
var count = 0;
$.getJSON(link + QUERY + "/json&callback=?", function( data ) {
$.each(data, function(i, item1) {
$.each(item1, function(j, item2){
if(j === 'syn'){
$.each(item2, function(k, item3){
if(typeof item3 !== 'undefined'){
count++;
addtoWSL(WSL, item3);
}
});
}
});
//console.log("FInished " + QUERY);
cb();
});
if (count !== 0 && count === WSL.length)
WSL.sort();
addtoWSL(WSL, QUERY);
//console.log(WSL.toString());
mergeSynList(WSL);
});
};
var convertDIC = function(){
var counter = 0;
$.each(wordlist, function(i, item){
getWSL(item, function() {
counter++;
if(counter === wordlist.length){
console.log(JSON.stringify(bigList));
}
});
});
}
var addtoWSL = function(list, word){
word.toLowerCase();
list.push(word);
}