From 4119aae88f2aadc7315466e7f77948880fc4a3c0 Mon Sep 17 00:00:00 2001 From: Jim Barrett Date: Thu, 15 Aug 2024 22:12:53 +0200 Subject: [PATCH 1/4] add some basic usage docs --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index fedfd53..34d5efa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,36 @@ # wrdcld A predictable, interpretable wordcloud library +`wrdcld` is available to install via pip + +```bash +pip install wrdcld +``` + +## Basic Usage + +To make a basic wordcloud, you simply pass a list of words to the `make_wordcloud` function. Here is a basic example generating a word cloud of the Sherlock Holmes story __The adventure of the dancing men__. + +```python +from pathlib import Path + +from wrdcld import make_word_cloud + +content = Path("examples/dancingmen.txt").read_text() + +all_words = [word.strip(" \n,.!?:-&\"'") for word in contents.split(" ")] +all_words = [word for word in all_words if word] + +make_word_cloud( + all_words=all_words, + font_color=(0, 0, 0), # RGB + background_color=(255, 255, 255), + minimum_font_size=5, +).show() +``` + +# Development + ## Setup Run `poetry install` From 81bd5b70d57e33b167df66a09600db46c7ad8e6c Mon Sep 17 00:00:00 2001 From: Jim Barrett Date: Thu, 15 Aug 2024 22:15:49 +0200 Subject: [PATCH 2/4] simplify the examples code --- README.md | 4 ++-- examples/sherlock.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 34d5efa..e643c76 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ from pathlib import Path from wrdcld import make_word_cloud -content = Path("examples/dancingmen.txt").read_text() +contents = Path("examples/dancingmen.txt").read_text() -all_words = [word.strip(" \n,.!?:-&\"'") for word in contents.split(" ")] +all_words = [word.strip(" \n,.!?:-&\"'[]") for word in contents.split(" ")] all_words = [word for word in all_words if word] make_word_cloud( diff --git a/examples/sherlock.py b/examples/sherlock.py index 31c0072..c69cf4c 100644 --- a/examples/sherlock.py +++ b/examples/sherlock.py @@ -2,10 +2,9 @@ from wrdcld import make_word_cloud -with open(Path("examples/dancingmen.txt"), encoding="utf-8") as f: - contents = f.read() +contents = Path("examples/dancingmen.txt").read_text() -all_words = [word.strip(" \n,.!?:-&\"'") for word in contents.split(" ")] +all_words = [word.strip(" \n,.!?:-&\"'[]") for word in contents.split(" ")] all_words = [word for word in all_words if word] make_word_cloud( From 167721ab0797d43f88bcfc1a7e0b640b1caf09d8 Mon Sep 17 00:00:00 2001 From: Jim Barrett Date: Thu, 15 Aug 2024 22:21:19 +0200 Subject: [PATCH 3/4] be explicit with encoding to make the linter happy --- README.md | 2 +- examples/sherlock.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e643c76..7a029d9 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ from pathlib import Path from wrdcld import make_word_cloud -contents = Path("examples/dancingmen.txt").read_text() +contents = Path("examples/dancingmen.txt").read_text(encoding="utf-8") all_words = [word.strip(" \n,.!?:-&\"'[]") for word in contents.split(" ")] all_words = [word for word in all_words if word] diff --git a/examples/sherlock.py b/examples/sherlock.py index c69cf4c..b157246 100644 --- a/examples/sherlock.py +++ b/examples/sherlock.py @@ -2,7 +2,7 @@ from wrdcld import make_word_cloud -contents = Path("examples/dancingmen.txt").read_text() +contents = Path("examples/dancingmen.txt").read_text(encoding="utf-8") all_words = [word.strip(" \n,.!?:-&\"'[]") for word in contents.split(" ")] all_words = [word for word in all_words if word] From e28953c6f380509c0d38d7934128199f7d4b2984 Mon Sep 17 00:00:00 2001 From: Jim Barrett Date: Fri, 16 Aug 2024 10:56:31 +0200 Subject: [PATCH 4/4] fix typo in basic docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a029d9..6c405e7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ pip install wrdcld ## Basic Usage -To make a basic wordcloud, you simply pass a list of words to the `make_wordcloud` function. Here is a basic example generating a word cloud of the Sherlock Holmes story __The adventure of the dancing men__. +To make a basic wordcloud, you simply pass a list of words to the `make_word_cloud` function. Here is a basic example generating a word cloud of the Sherlock Holmes story __The adventure of the dancing men__. ```python from pathlib import Path