Creating a word cloud data for web static exporter.
This commit is contained in:
parent
dc446f2026
commit
0577beb724
@ -0,0 +1,17 @@
|
|||||||
|
accessing
|
||||||
|
wordcloudData
|
||||||
|
|
||||||
|
| stopwords stopwordsCapitalized occurrencesWords wordAndValue |
|
||||||
|
stopwords := (TweetsCollection dataStore / 'commons' / 'stopwords-es.txt') contents splitOn: Character lf.
|
||||||
|
stopwordsCapitalized := stopwords collect: [:each | each first asString asUppercase, each allButFirst asLowercase ].
|
||||||
|
occurrencesWords := ((((self writeWordsFile contents) splitOn: ' ') asBag asDictionary)
|
||||||
|
associations asSortedCollection: [:x :y | x value > y value]) asOrderedDictionary.
|
||||||
|
occurrencesWords removeKeys: stopwords.
|
||||||
|
occurrencesWords removeKeys: stopwordsCapitalized.
|
||||||
|
occurrencesWords removeKey: ''.
|
||||||
|
wordAndValue := OrderedCollection new.
|
||||||
|
occurrencesWords keysAndValuesDo: [ :k :v |
|
||||||
|
wordAndValue add: ('{name:', ($' asString), k, ($' asString), ',value:', v asString, '}')
|
||||||
|
].
|
||||||
|
^ {'[', ((',' join: wordAndValue) copyWithout: Character lf), ']'.
|
||||||
|
occurrencesWords}
|
Loading…
Reference in New Issue
Block a user