Skip to content

Commit

Permalink
Merge pull request #13 from jimbarrett27/basic-usage-docs
Browse files Browse the repository at this point in the history
Basic usage docs
  • Loading branch information
jimbarrett27 authored Aug 16, 2024
2 parents 82e205f + dfe1845 commit a75fc83
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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_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

from wrdcld import make_word_cloud

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]

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`

Expand Down
5 changes: 2 additions & 3 deletions examples/sherlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(encoding="utf-8")

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(
Expand Down

0 comments on commit a75fc83

Please sign in to comment.