python - How can i make cloud of words occuring together? -


edit "please focus answer example below, no broad scenarios"

ok. have read word cloud. wondering how can represent words occuring in string variable in example below?:

var_x wireless problems, migration competitor dissatisfied customers, technicians visits scheduled call waiting, technicians visits bad customer experience, wireless problems 

so want is: ("wireless problems" , "technicians visits") representation in cloud. how can done?

this code produces frequency distribution of adjacent words can used underlying word cloud data:

from nltk import bigrams, freqdist nltk.tokenize import regexptokenizer operator import itemgetter  sent = 'wireless problems, migration competitor\n\ dissatisfied customers, technicians visits scheduled\n\ call waiting, technicians visits\n\ bad customer experience, wireless problems'  tokenizer = regexptokenizer(r'\w+') sent_words = tokenizer.tokenize(sent) freq_dist = freqdist(bigrams(sent_words))  k,v in sorted(freq_dist.items(), key=itemgetter(1), reverse=true):     print(k,v) 

output

('technicians', 'visits') 2 ('wireless', 'problems') 2 ('dissatisfied', 'customers') 1 ('bad', 'customer') 1 ('scheduled', 'call') 1 ('competitor', 'dissatisfied') 1 ('migration', 'to') 1 ('to', 'competitor') 1 ('visits', 'scheduled') 1 ('call', 'waiting') 1 ('problems', 'migration') 1 ('waiting', 'technicians') 1 ('customers', 'technicians') 1 ('customer', 'experience') 1 ('experience', 'wireless') 1 ('visits', 'bad') 1 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -