Coding Challenge #40.1: Word Counter in JavaScript

preview_player
Показать описание


Other Parts of this Challenge:

References:

Related Coding Challenges:

Timestamps:
0:00 Introduction
0:50 Let's get started!
1:30 Load the text
2:15 Make an array of all the words
4:00 So how do we do this? The algorithm!
5:45 Let's implement it in code
9:10 Ignoring numbers
10:30 Ignoring case sensitivity
11:00 Understanding the order in a JavaScript object
13:15 Sorting based on the value
18:30 Sorted list of the words based on word count
19:30 Things you can do
21:16 Thanks for watching!

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

#wordcounting #visualization #tfidf #p5js #processing #javascript #java
Рекомендации по теме
Комментарии
Автор

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.

mycomputerfund
Автор

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.

SonofThor
Автор

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)

Thiago-jmgr
Автор

Awesome video! Love your enthusiasm and clear explanations. Thanks so much for putting this up.

Aglaophamus
Автор

Thank you for being God bless you and yours this season 🎊🎉🙏

occieholloway
Автор

I'm not a javascript coder, but this has given me some good ideas elsewhere - thank you!

followthetrawler
Автор

7:20 You can also check "word in counts". Does anyone know if this makes some difference to his approach?

JakobRobert
Автор

I should probably go cold turkey on Coding Train. 3h+ lessons a day that's plenty :)

nocaster
Автор

you should have wayyyy more subscribers

elysel
Автор

I cannot find the fuction loadString in intelij. Any ideas how to find it?

twofacil
Автор

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?

diwasrai
Автор

the count.sort(compare) part is not working. It says a its undefined. Is that a p5 function or a javascript function?

FellTheSky
Автор

This no longer works. I am not sure if it is something to do with linking the txt to the html doc. Help?!

Ny_babs
Автор

What's the syntax theme do you use?

royopov
Автор

I'm confused on how the compare function works. What is a and b and how are we passing the into the function?

aaronbuckles
Автор

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!

setupdraw
Автор

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

KOKOMAKING
Автор

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?

jacekudi
Автор

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.

NonTwinBrothers
Автор

why not create an array of objects with both values in the first place ?

jerneje