adding mkdocs
This commit is contained in:
1
docs/about.md
Normal file
1
docs/about.md
Normal file
@@ -0,0 +1 @@
|
||||
# Some about page
|
||||
17
docs/index.md
Normal file
17
docs/index.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Welcome to MkDocs
|
||||
|
||||
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
|
||||
|
||||
## Commands
|
||||
|
||||
* `mkdocs new [dir-name]` - Create a new project.
|
||||
* `mkdocs serve` - Start the live-reloading docs server.
|
||||
* `mkdocs build` - Build the documentation site.
|
||||
* `mkdocs -h` - Print help message and exit.
|
||||
|
||||
## Project layout
|
||||
|
||||
mkdocs.yml # The configuration file.
|
||||
docs/
|
||||
index.md # The documentation homepage.
|
||||
... # Other markdown pages, images and other files.
|
||||
20
docs/python.md
Normal file
20
docs/python.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Some python
|
||||
|
||||
## Some test python
|
||||
|
||||
!!! warning "Important warning"
|
||||
This isn't yet complete.
|
||||
|
||||
```python
|
||||
def _generate_word_cloud(self) -> None:
|
||||
"""Generates a word cloud
|
||||
"""
|
||||
self.wc = WordCloud(
|
||||
max_words=150,
|
||||
width=1500,
|
||||
height=1500,
|
||||
mask=self.char_mask,
|
||||
random_state=1,
|
||||
).generate_from_frequencies(self.freq)
|
||||
return self
|
||||
```
|
||||
83
docs/test.md
Normal file
83
docs/test.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# musicbrainzapi.wordcloud package
|
||||
|
||||
Wordcloud from lyrics.
|
||||
|
||||
|
||||
### class musicbrainzapi.wordcloud.LyricsWordcloud(pillow_img: PIL.PngImagePlugin.PngImageFile, all_albums_lyrics_count: Lyrics.all_albums_lyrics_count)
|
||||
Bases: `object`
|
||||
|
||||
Create a word cloud from Lyrics.
|
||||
|
||||
|
||||
* **Variables**
|
||||
|
||||
|
||||
* **all_albums_lyrics_count** (*list*) – List of all albums + track lyrics counted by each word
|
||||
|
||||
|
||||
* **char_mask** (*np.array*) – numpy array containing data for the word cloud image
|
||||
|
||||
|
||||
* **freq** (*collections.Counter*) – Counter object containing counts for all words across all tracks
|
||||
|
||||
|
||||
* **lyrics_list** (*list*) – List of all words from all lyrics across all tracks.
|
||||
|
||||
|
||||
* **pillow_img** (*PIL.PngImagePlugin.PngImageFile*) – pillow image of the word cloud base
|
||||
|
||||
|
||||
* **wc** (*wordcloud.WordCloud*) – WordCloud object
|
||||
|
||||
|
||||
|
||||
#### \__init__(pillow_img: PIL.PngImagePlugin.PngImageFile, all_albums_lyrics_count: Lyrics.all_albums_lyrics_count)
|
||||
Create a worcloud object.
|
||||
|
||||
|
||||
* **Parameters**
|
||||
|
||||
|
||||
* **pillow_img** (*PIL.PngImagePlugin.PngImageFile*) – pillow image of the word cloud base
|
||||
|
||||
|
||||
* **all_albums_lyrics_count** (*Lyrics.all_albums_lyrics_count*) – List of all albums + track lyrics counted by each word
|
||||
|
||||
|
||||
|
||||
#### classmethod use_microphone(all_albums_lyrics_count: Lyrics.all_albums_lyrics_count)
|
||||
Class method to instantiate with a microphone base image.
|
||||
|
||||
|
||||
* **Parameters**
|
||||
|
||||
**all_albums_lyrics_count** (*Lyrics.all_albums_lyrics_count*) – List of all albums + track lyrics counted by each word
|
||||
|
||||
|
||||
|
||||
#### static generate_grey_colours(\*args, \*\*kwargs)
|
||||
Static method to generate a random grey colour.
|
||||
|
||||
|
||||
#### _get_lyrics_list()
|
||||
Gets all words from lyrics in a single list + cleans them.
|
||||
|
||||
|
||||
#### _get_frequencies()
|
||||
Get frequencies of words from a list.
|
||||
|
||||
|
||||
#### _get_char_mask()
|
||||
Gets a numpy array for the image file.
|
||||
|
||||
|
||||
#### _generate_word_cloud()
|
||||
Generates a word cloud
|
||||
|
||||
|
||||
#### _generate_plot()
|
||||
Plots the wordcloud and sets matplotlib options.
|
||||
|
||||
|
||||
#### create_word_cloud()
|
||||
Creates a word cloud
|
||||
5
docs/testdoc.md
Normal file
5
docs/testdoc.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Test documentation using mkdocstrings
|
||||
|
||||
## Reference
|
||||
|
||||
::: musicbrainzapi.api.lyrics.builder
|
||||
39
mkdocs.yml
Normal file
39
mkdocs.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
site_name: Musicbrainzapi
|
||||
|
||||
nav:
|
||||
- Welcome:
|
||||
- Home: index.md
|
||||
- About: about.md
|
||||
- API:
|
||||
- API: test.md
|
||||
- Code:
|
||||
- python.md
|
||||
- testdoc.md
|
||||
|
||||
# theme: material
|
||||
theme:
|
||||
name: "material"
|
||||
palette:
|
||||
primary: "yellow"
|
||||
accent: "red"
|
||||
feature:
|
||||
tabs: true
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
- codehilite:
|
||||
guess_lang: true
|
||||
- toc:
|
||||
permalink: true
|
||||
|
||||
plugins:
|
||||
- search
|
||||
- mkdocstrings
|
||||
|
||||
repo_name: "dtomlinson91/musicbrainzapi"
|
||||
repo_url: "https://github.com/dtomlinson91/musicbrainzapi-cv-airelogic"
|
||||
|
||||
extra:
|
||||
social:
|
||||
- type: "github"
|
||||
link: "https://github.com/dtomlinson91/musicbrainzapi"
|
||||
185
poetry.lock
generated
185
poetry.lock
generated
@@ -133,6 +133,14 @@ optional = false
|
||||
python-versions = "*"
|
||||
version = "0.2.1"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Clean single-source support for Python 3 and 2"
|
||||
name = "future"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
version = "0.18.2"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Internationalized Domain Names in Applications (IDNA)"
|
||||
@@ -212,6 +220,51 @@ optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
version = "1.4.3"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Python LiveReload is an awesome tool for web developers"
|
||||
name = "livereload"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "2.6.1"
|
||||
|
||||
[package.dependencies]
|
||||
six = "*"
|
||||
tornado = "*"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "A Python implementation of Lunr.js"
|
||||
name = "lunr"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "0.5.6"
|
||||
|
||||
[package.dependencies]
|
||||
future = ">=0.16.0"
|
||||
six = ">=1.11.0"
|
||||
|
||||
[package.dependencies.nltk]
|
||||
optional = true
|
||||
version = ">=3.2.5"
|
||||
|
||||
[package.extras]
|
||||
languages = ["nltk (>=3.2.5)"]
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Python implementation of Markdown."
|
||||
name = "markdown"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
version = "3.2.1"
|
||||
|
||||
[package.dependencies]
|
||||
setuptools = ">=36"
|
||||
|
||||
[package.extras]
|
||||
testing = ["coverage", "pyyaml"]
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Safely add untrusted strings to HTML/XML markup."
|
||||
@@ -243,6 +296,51 @@ optional = false
|
||||
python-versions = "*"
|
||||
version = "0.6.1"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Project documentation with Markdown."
|
||||
name = "mkdocs"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
version = "1.1"
|
||||
|
||||
[package.dependencies]
|
||||
Jinja2 = ">=2.10.1"
|
||||
Markdown = ">=3.2.1"
|
||||
PyYAML = ">=3.10"
|
||||
click = ">=3.3"
|
||||
livereload = ">=2.5.1"
|
||||
tornado = ">=5.0"
|
||||
|
||||
[package.dependencies.lunr]
|
||||
extras = ["languages"]
|
||||
version = "0.5.6"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "A Material Design theme for MkDocs"
|
||||
name = "mkdocs-material"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "4.6.3"
|
||||
|
||||
[package.dependencies]
|
||||
Pygments = ">=2.4"
|
||||
markdown = ">=3.2"
|
||||
mkdocs = ">=1.0"
|
||||
pymdown-extensions = ">=6.3"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Automatic documentation from docstrings, for mkdocs."
|
||||
name = "mkdocstrings"
|
||||
optional = false
|
||||
python-versions = ">=3.6,<4.0"
|
||||
version = "0.8.0"
|
||||
|
||||
[package.dependencies]
|
||||
mkdocs = ">=1.1"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "More routines for operating on iterables, beyond itertools"
|
||||
@@ -259,6 +357,25 @@ optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
version = "0.7.1"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Natural Language Toolkit"
|
||||
name = "nltk"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "3.4.5"
|
||||
|
||||
[package.dependencies]
|
||||
six = "*"
|
||||
|
||||
[package.extras]
|
||||
all = ["pyparsing", "scikit-learn", "python-crfsuite", "matplotlib", "scipy", "gensim", "requests", "twython", "numpy"]
|
||||
corenlp = ["requests"]
|
||||
machine_learning = ["gensim", "numpy", "python-crfsuite", "scikit-learn", "scipy"]
|
||||
plot = ["matplotlib"]
|
||||
tgrep = ["pyparsing"]
|
||||
twitter = ["twython"]
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Useful container datatypes for Python 2 and 3."
|
||||
@@ -500,6 +617,7 @@ watchdog = ">=0.10.2,<1.0.0"
|
||||
reference = "8465c4bd3e8ec7bc61b094b54f4a42c42a7551c6"
|
||||
type = "git"
|
||||
url = "https://github.com/NiklasRosenstein/pydoc-markdown.git"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Python docstring style checker"
|
||||
@@ -592,6 +710,17 @@ version = "0.6"
|
||||
[package.dependencies]
|
||||
pylint = ">=1.7"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Extension pack for Python Markdown."
|
||||
name = "pymdown-extensions"
|
||||
optional = false
|
||||
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*"
|
||||
version = "6.3"
|
||||
|
||||
[package.dependencies]
|
||||
Markdown = ">=3.2"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python parsing module"
|
||||
@@ -834,6 +963,14 @@ version = "1.1.4"
|
||||
lint = ["flake8", "mypy", "docutils-stubs"]
|
||||
test = ["pytest"]
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed."
|
||||
name = "tornado"
|
||||
optional = false
|
||||
python-versions = ">= 3.5"
|
||||
version = "6.0.4"
|
||||
|
||||
[[package]]
|
||||
category = "dev"
|
||||
description = "a fork of Python 2 and 3 ast modules with type comment support"
|
||||
@@ -929,7 +1066,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
|
||||
testing = ["jaraco.itertools", "func-timeout"]
|
||||
|
||||
[metadata]
|
||||
content-hash = "32d0df12af6ac6c77b7257af88db2930ef4f53fc59be766b1a7062ec502b9519"
|
||||
content-hash = "44fd20a54848c7d35be309d10766f8c4a4f3fdee8d661a1ad5088085ca5aca5e"
|
||||
python-versions = "^3.7"
|
||||
|
||||
[metadata.files]
|
||||
@@ -989,6 +1126,9 @@ dodgy = [
|
||||
{file = "dodgy-0.2.1-py3-none-any.whl", hash = "sha256:51f54c0fd886fa3854387f354b19f429d38c04f984f38bc572558b703c0542a6"},
|
||||
{file = "dodgy-0.2.1.tar.gz", hash = "sha256:28323cbfc9352139fdd3d316fa17f325cc0e9ac74438cbba51d70f9b48f86c3a"},
|
||||
]
|
||||
future = [
|
||||
{file = "future-0.18.2.tar.gz", hash = "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"},
|
||||
]
|
||||
idna = [
|
||||
{file = "idna-2.9-py2.py3-none-any.whl", hash = "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"},
|
||||
{file = "idna-2.9.tar.gz", hash = "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb"},
|
||||
@@ -1071,6 +1211,18 @@ lazy-object-proxy = [
|
||||
{file = "lazy_object_proxy-1.4.3-cp38-cp38-win32.whl", hash = "sha256:5541cada25cd173702dbd99f8e22434105456314462326f06dba3e180f203dfd"},
|
||||
{file = "lazy_object_proxy-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:59f79fef100b09564bc2df42ea2d8d21a64fdcda64979c0fa3db7bdaabaf6239"},
|
||||
]
|
||||
livereload = [
|
||||
{file = "livereload-2.6.1-py2.py3-none-any.whl", hash = "sha256:78d55f2c268a8823ba499305dcac64e28ddeb9a92571e12d543cd304faf5817b"},
|
||||
{file = "livereload-2.6.1.tar.gz", hash = "sha256:89254f78d7529d7ea0a3417d224c34287ebfe266b05e67e51facaf82c27f0f66"},
|
||||
]
|
||||
lunr = [
|
||||
{file = "lunr-0.5.6-py2.py3-none-any.whl", hash = "sha256:1208622930c915a07e6f8e8640474357826bad48534c0f57969b6fca9bffc88e"},
|
||||
{file = "lunr-0.5.6.tar.gz", hash = "sha256:7be69d7186f65784a4f2adf81e5c58efd6a9921aa95966babcb1f2f2ada75c20"},
|
||||
]
|
||||
markdown = [
|
||||
{file = "Markdown-3.2.1-py2.py3-none-any.whl", hash = "sha256:e4795399163109457d4c5af2183fbe6b60326c17cfdf25ce6e7474c6624f725d"},
|
||||
{file = "Markdown-3.2.1.tar.gz", hash = "sha256:90fee683eeabe1a92e149f7ba74e5ccdc81cd397bd6c516d93a8da0ef90b6902"},
|
||||
]
|
||||
markupsafe = [
|
||||
{file = "MarkupSafe-1.1.1-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161"},
|
||||
{file = "MarkupSafe-1.1.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"},
|
||||
@@ -1126,6 +1278,18 @@ mccabe = [
|
||||
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
|
||||
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
|
||||
]
|
||||
mkdocs = [
|
||||
{file = "mkdocs-1.1-py2.py3-none-any.whl", hash = "sha256:1e385a70aea8a9dedb731aea4fd5f3704b2074801c4f96f06b2920999babda8a"},
|
||||
{file = "mkdocs-1.1.tar.gz", hash = "sha256:9243291392f59e20b655e4e46210233453faf97787c2cf72176510e868143174"},
|
||||
]
|
||||
mkdocs-material = [
|
||||
{file = "mkdocs-material-4.6.3.tar.gz", hash = "sha256:1d486635b03f5a2ec87325842f7b10c7ae7daa0eef76b185572eece6a6ea212c"},
|
||||
{file = "mkdocs_material-4.6.3-py2.py3-none-any.whl", hash = "sha256:7f3afa0a09c07d0b89a6a9755fdb00513aee8f0cec3538bb903325c80f66f444"},
|
||||
]
|
||||
mkdocstrings = [
|
||||
{file = "mkdocstrings-0.8.0-py3-none-any.whl", hash = "sha256:b8ac4c8b0e79fec2877cbedaf43b9a215c3cbf6c553dcc4e5acd5021bf47a607"},
|
||||
{file = "mkdocstrings-0.8.0.tar.gz", hash = "sha256:1d12e3e34c63a05487321abdce052ceac3159a75b1ff5eadde5682ddcbb1caf5"},
|
||||
]
|
||||
more-itertools = [
|
||||
{file = "more-itertools-8.2.0.tar.gz", hash = "sha256:b1ddb932186d8a6ac451e1d95844b382f55e12686d51ca0c68b6f61f2ab7a507"},
|
||||
{file = "more_itertools-8.2.0-py3-none-any.whl", hash = "sha256:5dd8bcf33e5f9513ffa06d5ad33d78f31e1931ac9a18f33d37e77a180d393a7c"},
|
||||
@@ -1134,6 +1298,10 @@ musicbrainzngs = [
|
||||
{file = "musicbrainzngs-0.7.1-py2.py3-none-any.whl", hash = "sha256:e841a8f975104c0a72290b09f59326050194081a5ae62ee512f41915090e1a10"},
|
||||
{file = "musicbrainzngs-0.7.1.tar.gz", hash = "sha256:ab1c0100fd0b305852e65f2ed4113c6de12e68afd55186987b8ed97e0f98e627"},
|
||||
]
|
||||
nltk = [
|
||||
{file = "nltk-3.4.5.win32.exe", hash = "sha256:a08bdb4b8a1c13de16743068d9eb61c8c71c2e5d642e8e08205c528035843f82"},
|
||||
{file = "nltk-3.4.5.zip", hash = "sha256:bed45551259aa2101381bbdd5df37d44ca2669c5c3dad72439fa459b29137d94"},
|
||||
]
|
||||
"nr.collections" = [
|
||||
{file = "nr.collections-0.0.1.tar.gz", hash = "sha256:ddf38cd6379cac546ce7abdadf024fc01cca75540e11b1d5f1aa701a33817f1c"},
|
||||
]
|
||||
@@ -1267,6 +1435,10 @@ pylint-plugin-utils = [
|
||||
{file = "pylint-plugin-utils-0.6.tar.gz", hash = "sha256:57625dcca20140f43731311cd8fd879318bf45a8b0fd17020717a8781714a25a"},
|
||||
{file = "pylint_plugin_utils-0.6-py3-none-any.whl", hash = "sha256:2f30510e1c46edf268d3a195b2849bd98a1b9433229bb2ba63b8d776e1fc4d0a"},
|
||||
]
|
||||
pymdown-extensions = [
|
||||
{file = "pymdown-extensions-6.3.tar.gz", hash = "sha256:cb879686a586b22292899771f5e5bc3382808e92aa938f71b550ecdea709419f"},
|
||||
{file = "pymdown_extensions-6.3-py2.py3-none-any.whl", hash = "sha256:66fae2683c7a1dac53184f7de57f51f8dad73f9ead2f453e94e85096cb811335"},
|
||||
]
|
||||
pyparsing = [
|
||||
{file = "pyparsing-2.4.6-py2.py3-none-any.whl", hash = "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec"},
|
||||
{file = "pyparsing-2.4.6.tar.gz", hash = "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f"},
|
||||
@@ -1350,6 +1522,17 @@ sphinxcontrib-serializinghtml = [
|
||||
{file = "sphinxcontrib-serializinghtml-1.1.4.tar.gz", hash = "sha256:eaa0eccc86e982a9b939b2b82d12cc5d013385ba5eadcc7e4fed23f4405f77bc"},
|
||||
{file = "sphinxcontrib_serializinghtml-1.1.4-py2.py3-none-any.whl", hash = "sha256:f242a81d423f59617a8e5cf16f5d4d74e28ee9a66f9e5b637a18082991db5a9a"},
|
||||
]
|
||||
tornado = [
|
||||
{file = "tornado-6.0.4-cp35-cp35m-win32.whl", hash = "sha256:5217e601700f24e966ddab689f90b7ea4bd91ff3357c3600fa1045e26d68e55d"},
|
||||
{file = "tornado-6.0.4-cp35-cp35m-win_amd64.whl", hash = "sha256:c98232a3ac391f5faea6821b53db8db461157baa788f5d6222a193e9456e1740"},
|
||||
{file = "tornado-6.0.4-cp36-cp36m-win32.whl", hash = "sha256:5f6a07e62e799be5d2330e68d808c8ac41d4a259b9cea61da4101b83cb5dc673"},
|
||||
{file = "tornado-6.0.4-cp36-cp36m-win_amd64.whl", hash = "sha256:c952975c8ba74f546ae6de2e226ab3cc3cc11ae47baf607459a6728585bb542a"},
|
||||
{file = "tornado-6.0.4-cp37-cp37m-win32.whl", hash = "sha256:2c027eb2a393d964b22b5c154d1a23a5f8727db6fda837118a776b29e2b8ebc6"},
|
||||
{file = "tornado-6.0.4-cp37-cp37m-win_amd64.whl", hash = "sha256:5618f72e947533832cbc3dec54e1dffc1747a5cb17d1fd91577ed14fa0dc081b"},
|
||||
{file = "tornado-6.0.4-cp38-cp38-win32.whl", hash = "sha256:22aed82c2ea340c3771e3babc5ef220272f6fd06b5108a53b4976d0d722bcd52"},
|
||||
{file = "tornado-6.0.4-cp38-cp38-win_amd64.whl", hash = "sha256:c58d56003daf1b616336781b26d184023ea4af13ae143d9dda65e31e534940b9"},
|
||||
{file = "tornado-6.0.4.tar.gz", hash = "sha256:0fe2d45ba43b00a41cd73f8be321a44936dc1aba233dee979f17a042b83eb6dc"},
|
||||
]
|
||||
typed-ast = [
|
||||
{file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3"},
|
||||
{file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb"},
|
||||
|
||||
@@ -27,6 +27,10 @@ sphinx-click = "^2.3.1"
|
||||
prospector = "^1.2.0"
|
||||
pylint = "^2.4.4"
|
||||
pydoc-markdown = {git = "https://github.com/NiklasRosenstein/pydoc-markdown.git", rev = "develop"}
|
||||
mkdocs = "^1.1"
|
||||
mkdocs-material = "^4.6.3"
|
||||
pymdown-extensions = "^6.3"
|
||||
mkdocstrings = "^0.8.0"
|
||||
|
||||
[tool.poetry.plugins."console_scripts"]
|
||||
"musicbrainzapi" = "musicbrainzapi.cli.cli:cli"
|
||||
|
||||
@@ -20,59 +20,57 @@ if typing.TYPE_CHECKING:
|
||||
import PIL.PngImagePlugin.PngImageFile
|
||||
|
||||
|
||||
# pylint:disable=line-too-long
|
||||
class LyricsWordcloud:
|
||||
"""Create a word cloud from Lyrics.
|
||||
"""
|
||||
Create a Wordcloud from Lyrics.
|
||||
|
||||
The docstring continues here.
|
||||
|
||||
It should contain:
|
||||
|
||||
- something
|
||||
- something else
|
||||
|
||||
Args:
|
||||
pillow_img (PIL.PngImagePlugin.PngImageFile): pillow image of the word
|
||||
cloud base
|
||||
all_albums_lyrics_count (dict): A dictionary containing the lyrics from
|
||||
a whole album.
|
||||
|
||||
!!! Attributes
|
||||
|
||||
- `pillow_img` (pillow): A pillow image.
|
||||
|
||||
Anything else can go here.
|
||||
|
||||
Example:
|
||||
Here is how you can use it
|
||||
|
||||
Attributes
|
||||
----------
|
||||
all_albums_lyrics_count : list
|
||||
List of all albums + track lyrics counted by each word
|
||||
char_mask : np.array
|
||||
numpy array containing data for the word cloud image
|
||||
freq : collections.Counter
|
||||
Counter object containing counts for all words across all tracks
|
||||
lyrics_list : list
|
||||
List of all words from all lyrics across all tracks.
|
||||
pillow_img : PIL.PngImagePlugin.PngImageFile
|
||||
pillow image of the word cloud base
|
||||
wc : wordcloud.WordCloud
|
||||
WordCloud object
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
pillow_img: 'PIL.PngImagePlugin.PngImageFile',
|
||||
all_albums_lyrics_count: 'Lyrics.all_albums_lyrics_count',
|
||||
pillow_img: "PIL.PngImagePlugin.PngImageFile",
|
||||
all_albums_lyrics_count: "Lyrics.all_albums_lyrics_count",
|
||||
):
|
||||
"""
|
||||
Create a worcloud object.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
pillow_img : PIL.PngImagePlugin.PngImageFile
|
||||
pillow image of the word cloud base
|
||||
all_albums_lyrics_count : Lyrics.all_albums_lyrics_count
|
||||
List of all albums + track lyrics counted by each word
|
||||
"""
|
||||
self.pillow_img = pillow_img
|
||||
self.all_albums_lyrics_count = all_albums_lyrics_count
|
||||
self.test = []
|
||||
|
||||
@classmethod
|
||||
def use_microphone(
|
||||
cls, all_albums_lyrics_count: 'Lyrics.all_albums_lyrics_count',
|
||||
cls, all_albums_lyrics_count: "Lyrics.all_albums_lyrics_count",
|
||||
) -> LyricsWordcloud:
|
||||
"""
|
||||
Class method to instantiate with a microphone base image.
|
||||
"""Create a LyricsWordcloud using a microphone as a base image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
all_albums_lyrics_count : Lyrics.all_albums_lyrics_count
|
||||
List of all albums + track lyrics counted by each word
|
||||
Args:
|
||||
all_albums_lyrics_count (dict): A dictionary containing the lyrics from a whole album.
|
||||
Returns:
|
||||
LyricsWordcloud: Instance of itself with a micrphone image loaded in.
|
||||
|
||||
"""
|
||||
mic_resource = resources.path(
|
||||
'musicbrainzapi.wordcloud.resources', 'mic.png'
|
||||
)
|
||||
mic_resource = resources.path("musicbrainzapi.wordcloud.resources", "mic.png")
|
||||
with mic_resource as m:
|
||||
mic_img = Image.open(m)
|
||||
|
||||
@@ -86,9 +84,14 @@ class LyricsWordcloud:
|
||||
*args,
|
||||
**kwargs,
|
||||
) -> str:
|
||||
"""Static method to generate a random grey colour."""
|
||||
colour = f'hsl(0, 0%, {random.randint(60, 100)}%)'
|
||||
return colour
|
||||
"""Static method to return a random grey color.
|
||||
|
||||
Returns:
|
||||
str: A random grey colour in `hsl` form.
|
||||
|
||||
Can be any grey colour.
|
||||
"""
|
||||
return f"hsl(0, 0%, {random.randint(60, 100)}%)"
|
||||
|
||||
def _get_lyrics_list(self) -> None:
|
||||
"""Gets all words from lyrics in a single list + cleans them.
|
||||
@@ -101,12 +104,8 @@ class LyricsWordcloud:
|
||||
for word in track:
|
||||
for _ in range(1, word[1]):
|
||||
cleaned = word[0]
|
||||
cleaned = re.sub(
|
||||
r'[\(\[].*?[\)\]]', ' ', cleaned
|
||||
)
|
||||
cleaned = re.sub(
|
||||
r'[^a-zA-Z0-9\s]', '', cleaned
|
||||
)
|
||||
cleaned = re.sub(r"[\(\[].*?[\)\]]", " ", cleaned)
|
||||
cleaned = re.sub(r"[^a-zA-Z0-9\s]", "", cleaned)
|
||||
cleaned = cleaned.lower()
|
||||
if cleaned in STOPWORDS:
|
||||
continue
|
||||
@@ -129,11 +128,7 @@ class LyricsWordcloud:
|
||||
"""Generates a word cloud
|
||||
"""
|
||||
self.wc = WordCloud(
|
||||
max_words=150,
|
||||
width=1500,
|
||||
height=1500,
|
||||
mask=self.char_mask,
|
||||
random_state=1,
|
||||
max_words=150, width=1500, height=1500, mask=self.char_mask, random_state=1,
|
||||
).generate_from_frequencies(self.freq)
|
||||
return self
|
||||
|
||||
@@ -141,12 +136,10 @@ class LyricsWordcloud:
|
||||
"""Plots the wordcloud and sets matplotlib options.
|
||||
"""
|
||||
plt.imshow(
|
||||
self.wc.recolor(
|
||||
color_func=self.generate_grey_colours, random_state=3
|
||||
),
|
||||
interpolation='bilinear',
|
||||
self.wc.recolor(color_func=self.generate_grey_colours, random_state=3),
|
||||
interpolation="bilinear",
|
||||
)
|
||||
plt.axis('off')
|
||||
plt.axis("off")
|
||||
return self
|
||||
|
||||
# def show_word_cloud(self):
|
||||
|
||||
Reference in New Issue
Block a user