word-cloud

Python WordCloud meet AttributeError: 'list' object has no attribute 'items'

人盡茶涼 提交于 2019-12-11 03:47:26
问题 When I using WordCloud function .fit_words(), I met AttributeError: 'list' object has no attribute 'items' . It also doesn't work when I using .generate_from_frequencies(). How to figure it out? All suggestion will be appreciated. code: wordcloud = WordCloud(font_path="simhei.ttf", background_color="white", max_font_size=80) word_frequence = {x[0]: x[1] for x in words_stat.head(1000).values} word_frequence_list = [] for key in word_frequence: temp = (key, word_frequence[key]) word_frequence

How to subset an item:value list using another list with just items?

こ雲淡風輕ζ 提交于 2019-12-10 19:37:53
问题 I have 2 lists. One is a list of words and their frequencies and the other is a list of words. a = [('country',3478), ('island',2900),('river',5)] b = ['river','mountain','bank'] There are thousands of entries in a but only hundreds in b. How can I subset list a so that i return: c=[('river',5)] For loops would take too long given the number of entries and i imagine list comprehension is the solution but cannot get it right. My main goal is to then create a wordcloud with my final list. Any

“import”ing d3 and d3-cloud with webpack

可紊 提交于 2019-12-10 18:06:15
问题 So, I have been trying to import d3 and d3-cloud(for word cloud) into my AngularJs(v - 1.4) app. I am doing this by - import d3 from 'd3' import d3Cloud from 'd3-cloud' . When I try to use to d3-cloud like d3.layout.cloud() I get the following error _d2.default.layout.cloud is not a function 回答1: import { Component, Input, AfterViewInit } from '@angular/core'; // import and assign libs ** import d3 from 'd3' import * as cloud from 'd3-cloud' @Component({ selector: 'word-cloud', templateUrl: '

R {wordcloud} package, what do the values in scale represent?

我只是一个虾纸丫 提交于 2019-12-10 15:48:17
问题 This seems like a simple question, but I can't seem to find an answer anywhere. In the R {wordcloud} package, the wordcloud function, there is a scale value that you can enter. The full documentation (here: https://cran.r-project.org/web/packages/wordcloud/wordcloud.pdf) says: "A vector of length 2 indicating the range of the size of the words." I can't seem to make any sense of the values though, and I can't find any other documentation. For instance, examples have scale=c(4,.5) or scale=c(8

r wordcloud external ttf vfont not recognized

隐身守侯 提交于 2019-12-09 12:43:01
问题 I've installed the 'extrafont' package in order to install an external font library Duality via the ttf_import() method. However, when specifying the font via the wordcloud method, I receive the following error: Installation command: # Assuming the font file, DUALITY_.ttf, is in the working directory (see link to font above) font_import(".",FALSE,pattern="DUALITY") Wordcloud command: wordcloud(ap.d$word, ap.d$freq, scale=c(8,2), min.freq=10, vfont=c("Duality","plain"), random.order=FALSE, rot

Create a WORD CLOUD in Google Data Studio

痞子三分冷 提交于 2019-12-08 14:10:28
问题 I'm trying to create a word cloud in Google data studio. In order to do that as quickly as I can I wanted to use the community visualization. (https://github.com/pcperini/GDS-Word-Cloud , https://marketlytics.com/blog/custom-visualizations-data-studio ). Unfortunately anytime I try to insert the manifest path (gs://gds-word-cloud-prod) in the community visualization archive, it doesn't find anything. Do you have any suggestions? Am I doing something wrong? Are these visualization too old?

How to Save the wordcloud in R [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-12-08 11:35:35
问题 This question already has an answer here : Is there any way to show a wordcloud2 in Rmarkdown as a PDF or Word file? (1 answer) Closed 8 months ago . Can you please help to save word cloud on my local drive as an image?, I am looking for a code/command to get it done automatically through R Programming. I have tried with saveWidget , plotly , orca but not get success. I have used below code to create the word cloud. library(wordcloud2) wordcloud2(demoFreqC, figPath = figPath,color =

d3.js word missing from word cloud

独自空忆成欢 提交于 2019-12-07 21:17:14
问题 js and trying to do word cloud base on the sample code from [here]: https://github.com/jasondavies/d3-cloud. What i trying to do is the font size of the words is base on the frequency of the words in array. For example i have [a,a,a,b,b] so the word 'a' will be larger than 'b' but the problem is when the width or height of the word is larger than the < svg > the word will be gone. layout = d3.layout.cloud().size([w, h]) .words(frequency_list) .padding(5) .rotate(function() { return ~~(Math

Wordcloud showing colour based on continous metadata in R

半城伤御伤魂 提交于 2019-12-06 12:35:58
I'm creating a wordcloud in which the size of the words is based on frequency, but i want the colour of the words to be mapped to a third variable (stress, which is the amount of stress associated with each word, a numerical or continuous variable). I tried the following, which gave me only two different colours (yellow and purple) while i want something more smooth. I would like some color range like a palette that goes from green to red for example. df = data.frame(word = c("calling", "meeting", "conference", "contract", "negotiation", "email"), n = c(20, 12, 4, 8, 10, 43), stress = c(23, 30

How to put a wordcloud in a grob?

旧街凉风 提交于 2019-12-06 12:13:13
问题 I've created a simple wordcloud: require(wordcloud) words <- c('affectionate', 'ambitious', 'anxious', 'articulate', 'artistic', 'caring', 'contented', 'creative', 'cynical', 'daring', 'dependable', 'easygoing', 'energetic', 'funny', 'generous', 'genuine', 'goodlistener', 'goodtalker', 'happy', 'hardworking', 'humerous', 'impulsive', 'intelligent', 'kind', 'loyal', 'modest', 'optimistic', 'outgoing', 'outrageous', 'passionate', 'perceptive', 'physicallyfit', 'quiet', 'rational', 'respectful',