From 0577beb724b86729d2b8b785f86f5425a97dd940 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Thu, 9 Jun 2022 11:53:27 -0500 Subject: [PATCH] Creating a word cloud data for web static exporter. --- .../NitterUser.class/instance/wordcloudData.st | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Socialmetrica.package/NitterUser.class/instance/wordcloudData.st diff --git a/Socialmetrica.package/NitterUser.class/instance/wordcloudData.st b/Socialmetrica.package/NitterUser.class/instance/wordcloudData.st new file mode 100644 index 0000000..9e144f1 --- /dev/null +++ b/Socialmetrica.package/NitterUser.class/instance/wordcloudData.st @@ -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} \ No newline at end of file