xxxxxxxxxx
42
let words=[];
let word_count={};
let p;
let str;
function preload() {
loadStrings('turkey.txt',process);
// turkey= loadStrings('turkey.txt');
}
function setup() {
createCanvas(400, 400);
textAlign(LEFT,TOP);
// p=createP();
}
function draw(){
for(let word in word_count){
let count=word_count[word];
textSize(50);// i'm not sure
}
}
function process(lines){
for(let line of lines){
let tokens=splitTokes(line);
words=words.concat(tokens);
}
console.log(words);
// for(let l in lines){
// console.log(l);
//}
for(let w in words){
let word=words[w];
word=word.replace(/[.,:;?!\(\)\-_]/g,'');
word=word.toLowerCase();
word=word.trim();
if(word.length<1)words.splice(w,1);
else words[w]=word;
}
for(let word of words){
if(word in word_count)word_count[word]++;
else word_count[word]=1;
}
console.log(word_count);
}