It's disrespectful that this video has 20k views and only 280 likes... This content is excellent. I love your explanation and 'hand-holding' of concepts. You're a natural teacher.
Just found your videos. Man, you're such a great teacher! Your enthusiasm and expertise make it so fun AND easy to learn these complex topics. Well done, sir.
I have a noob question. On the if statement, how does incrementing an 'object "key" equals the increase in count in "value" ? I understand the declaration of value to 1, if the word (aka counts[word] ) is undefined. But if it exists why does counts[word]++ define the value of the key?
I've noticed that if you just use if (counts[word]) { ..... It is not working properly , infact I got NAN instead of the numbers. So I think (counts[word] === undefined) is necesssary. Can anyone explain the reason for that? Another thing I do not understand completely is how the function compare(a,b){.... works. What gets passed in and how the ordering is made is quite obscure to me. BTW Great Coding Challenge Dan!
I've always loved and hated learning string patterns. They're extremely useful to use and make you look super smart but they're terribly hard to learn.
you could use something like "find" (developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find) for the lookup, just not sure how efficient it would be. But in your case it seems tedious, to manage multiple data sources
Would this algorithm be faster than, say, taking the first word, creating a copy of the word and keeping a count in a tuple, and then counting every occurrence of that word in the string before replacing each one with a blank space or other symbol that the loop can recognize and skip over? That is to say, each new word it encounters, it takes a new count of that word and replaces each occurrence with a symbol to be skipped over in the next cycle through the string. You could probably use that as a way to parallelize it, as well, with a new thread for each new word or something. IF you did it like that, I imagine you'd make a head thread that has a list of the already seen words, and it would kick off a new thread for each new word it found. In that case, it wouldn't even have to use the replace idea, it could just not start new threads for already seen words.
hello everybody, I got this rather tedious way for excluding some words in the counter: for (var j = 0; j < keys.length; j++) { var k = keys[j]; if (k != 'the' && k != 'and' && k != 'of' && k != 'to' && k != 'a' && k != 'in') { createDiv(" " + k + " " + counts[k]); } } can we make it with array difference in p5? Some shorter solution?
Jacek Patryk Urbanowicz would be much easier to put your words that you don't want in array like so: skipWords = ['the', 'so', 'and']; for (var i=0; i < skipWords.length; i++) { if (k==skipWords[i]) { createDiv(k) break } put that in your for loop. hope it helps, I'm on mobile!
You have a HUGE!!!! problem. What if, by accident, you have a word that is part of the prototype? That should break some stuff. What you can do is to append a NULL-char at the beginning. That is, instead of `counts[key]`, you use `counts['\0' + key]` everywhere where you have to access `key`.
It's disrespectful that this video has 20k views and only 280 likes... This content is excellent. I love your explanation and 'hand-holding' of concepts. You're a natural teacher.
Just found your videos. Man, you're such a great teacher! Your enthusiasm and expertise make it so fun AND easy to learn these complex topics. Well done, sir.
Thank you for being God bless you and yours this season 🎊🎉🙏
Awesome video! Love your enthusiasm and clear explanations. Thanks so much for putting this up.
Thanks so much!
I'm not a javascript coder, but this has given me some good ideas elsewhere - thank you!
Another ways you can count words frequency:
var arr = 'This is a sample'.split(/\W+/)
const freq = {}
const getWordsFreq = wordsArr => wordsArr.reduce((freq, word) => {
freq[word] = ++freq[word] || 1
return freq
}, {})
getWordsFreq(arr)
*Or alternatively in ONE line:*
const getWordsFreq = words => words.forEach(word => freq[word] = ++freq[word] || 1)
what about bigrams?
Thank you
you are best coder in my opinion!
7:20 You can also check "word in counts". Does anyone know if this makes some difference to his approach?
I should probably go cold turkey on Coding Train. 3h+ lessons a day that's plenty :)
Great one. Thanks :)
you should have wayyyy more subscribers
only a matter of time
This channel is LIT💕
I have a noob question. On the if statement, how does incrementing an 'object "key" equals the increase in count in "value" ? I understand the declaration of value to 1, if the word (aka counts[word] ) is undefined. But if it exists why does counts[word]++ define the value of the key?
I cannot find the fuction loadString in intelij. Any ideas how to find it?
What's the syntax theme do you use?
He's coding in JavaScript with the p5.js library.
the count.sort(compare) part is not working. It says a its undefined. Is that a p5 function or a javascript function?
I'm confused on how the compare function works. What is a and b and how are we passing the into the function?
Same with me.
Could you figure it out in the meantime?
god bless you sir!
This no longer works. I am not sure if it is something to do with linking the txt to the html doc. Help?!
thanks coach
I've noticed that if you just use if (counts[word]) { ..... It is not working properly , infact I got NAN instead of the numbers. So I think (counts[word] === undefined) is necesssary. Can anyone explain the reason for that?
Another thing I do not understand completely is how the function compare(a,b){.... works.
What gets passed in and how the ordering is made is quite obscure to me.
BTW Great Coding Challenge Dan!
I've always loved and hated learning string patterns. They're extremely useful to use and make you look super smart but they're terribly hard to learn.
Genius! :)
Genius
hi. i just want to make spelling bee aplication in javascript, but i don't know how to make the code. can you tell me how to make it ? thnks
Oh, I like this idea! Please suggest here! github.com/CodingTrain/Rainbow-Topics/issues
How did he get that console????
on chrome go to developer-tools or on firefox cmd-alt-i
why not create an array of objects with both values in the first place ?
Having the array only does not allow lookup by the word itself.
you could use something like "find" (developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find) for the lookup, just not sure how efficient it would be.
But in your case it seems tedious, to manage multiple data sources
Would this algorithm be faster than, say, taking the first word, creating a copy of the word and keeping a count in a tuple, and then counting every occurrence of that word in the string before replacing each one with a blank space or other symbol that the loop can recognize and skip over? That is to say, each new word it encounters, it takes a new count of that word and replaces each occurrence with a symbol to be skipped over in the next cycle through the string.
You could probably use that as a way to parallelize it, as well, with a new thread for each new word or something. IF you did it like that, I imagine you'd make a head thread that has a list of the already seen words, and it would kick off a new thread for each new word it found. In that case, it wouldn't even have to use the replace idea, it could just not start new threads for already seen words.
hello everybody, I got this rather tedious way for excluding some words in the counter:
for (var j = 0; j < keys.length; j++) {
var k = keys[j];
if (k != 'the' &&
k != 'and' &&
k != 'of' &&
k != 'to' &&
k != 'a' &&
k != 'in') {
createDiv(" " + k + " " + counts[k]);
}
}
can we make it with array difference in p5? Some shorter solution?
Jacek Patryk Urbanowicz would be much easier to put your words that you don't want in array like so:
skipWords = ['the', 'so', 'and'];
for (var i=0; i < skipWords.length; i++) {
if (k==skipWords[i]) {
createDiv(k)
break
}
put that in your for loop. hope it helps, I'm on mobile!
He should've counted the word frequencies of the Bee movie script instead... :P
Do you know a method for hyphenation?
Excuse me: separate into distinct syllables
Wait, why do we always use p5.js? Why not just javascript? Is using just javascript too advanced?
Word counter with graph :- codingflag.in/mysketch.php?sketch=95
You have a HUGE!!!! problem. What if, by accident, you have a word that is part of the prototype? That should break some stuff. What you can do is to append a NULL-char at the beginning. That is, instead of `counts[key]`, you use `counts['\0' + key]` everywhere where you have to access `key`.
I thought this would be made in pure Javascript. Not useful for me.