Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions wordcloud/wordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import colorsys
import matplotlib
import numpy as np
import json
from operator import itemgetter
from xml.sax import saxutils

Expand Down Expand Up @@ -1037,3 +1038,17 @@ def _draw_contour(self, img):
ret += np.array(color) * contour

return Image.fromarray(ret)

def save_frequency(self, file_name):
"""Save the frequency of the words and frequencies to a file."""
with open(file_name, 'w') as fp:
json.dump(self.words_, fp)

return

def generate_from_frequencies_file(self, frequencies_file, max_font_size=None):
"""Create a word_cloud from a words and frequencies JSON file."""
with open(frequencies_file, 'r') as fp:
frequencies = json.load(fp)

return self.generate_from_frequencies(frequencies, max_font_size):