jasondavies / d3-cloud

Create word clouds in JavaScript.
https://www.jasondavies.com/wordcloud/
Other
3.82k stars 1.07k forks source link

Set Number of words #111

Closed diggetybo closed 7 years ago

diggetybo commented 7 years ago

I would like to adjust the number of words that the word cloud accepts. I have a two part question.

  1. After I parse the full text of a text file into javascript, if I wanted to limit the number of words that I feed into cloud.js to save on computational resources, how would I access a subset of the word_count object? I presume the word_count object has not been ordered by frequency before the cloud is called? I would like to select the top k of the word_count object, let's say the top 20 words. Can someone advise on what that entails?

  2. If I wanted to instead limit the number of words the cloud.js accepts from the full parsed text file, is there anything built in that can do that? I didn't see anything like .maxwords(). Again, depending on when the word_count object is ordered from most frequent to least frequent, will have bearing on the words it needs.

As much of the algorithm is over my head, I don't want to end up editing at the wrong portion of the code and potentially confront the possibility of important/frequent/"unique" words that I'm mainly interested in being dropped out. That's why I prefer to first consult the existing expert community here.

Please advise,

Thank you

jasondavies commented 7 years ago

This issue tracker is for bug reports and feature requests only; please use StackOverflow or similar for general help.