Skip to main content

Visualization Module for Natural Language Processing

Project description

📝 nlplot

nlplot: Analysis and visualization module for Natural Language Processing 📈

Description

Facilitates the visualization of natural language processing and provides quicker analysis

You can draw the following graph

  1. N-gram bar chart
  2. N-gram tree Map
  3. Histogram of the word count
  4. wordcloud
  5. co-occurrence networks
  6. sunburst chart

(Tested in English and Japanese)

Requirement

Installation

pip install nlplot

I've posted on this blog about the specific use. (Japanese)

And, The sample code is also available in the kernel of kaggle. (English)

Quick start - Data Preparation

The column to be analyzed must be a space-delimited string

# sample data
target_col = "text"
texts = [
    "Think rich look poor",
    "When you come to a roadblock, take a detour",
    "When it is dark enough, you can see the stars",
    "Never let your memories be greater than your dreams",
    "Victory is sweetest when you’ve known defeat"
    ]
df = pd.DataFrame({target_col: texts})
df.head()
text
0 Think rich look poor
1 When you come to a roadblock, take a detour
2 When it is dark enough, you can see the stars
3 Never let your memories be greater than your dreams
4 Victory is sweetest when you’ve known defeat

Quick start - Python API

import nlplot

# target_col as a list type or a string separated by a space.
npt = nlplot.NLPlot(df, target_col='text')

# Stopword calculations can be performed.
stopwords = npt.get_stopword(top_n=30, min_freq=0)

# 1. N-gram bar chart
npt.bar_ngram(title='uni-gram', ngram=1, top_n=50, stopwords=stopwords)
npt.bar_ngram(title='bi-gram', ngram=2, top_n=50, stopwords=stopwords)

# 2. N-gram tree Map
npt.treemap(title='Tree of Most Common Words', ngram=1, top_n=30, stopwords=stopwords)

# 3. Histogram of the word count
npt.word_distribution(title='words distribution')

# 4. wordcloud
npt.wordcloud(stopwords=stopwords, colormap='tab20_r')

# 5. co-occurrence networks
npt.build_graph(stopwords=stopwords, min_edge_frequency=10)
# The number of nodes and edges to which this output is plotted.
# If this number is too large, plotting will take a long time, so adjust the [min_edge_frequency] well.
>> node_size:70, edge_size:166
npt.co_network(title='Co-occurrence network')

# 6. sunburst chart
npt.sunburst(title='sunburst chart', colorscale=True)

Document

TBD

Test

cd tests
pytest

Other

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nlplot-1.4.0.tar.gz (968.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nlplot-1.4.0-py3-none-any.whl (967.1 kB view details)

Uploaded Python 3

File details

Details for the file nlplot-1.4.0.tar.gz.

File metadata

  • Download URL: nlplot-1.4.0.tar.gz
  • Upload date:
  • Size: 968.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for nlplot-1.4.0.tar.gz
Algorithm Hash digest
SHA256 89560b2e45b56c02691065b6df4ef4b8c2f1e49e024399094e4404c2e261cbb2
MD5 5a17b78a5a6fe1f57287b720f559069c
BLAKE2b-256 8a38dd9d65ce070113a09a6082fc487a9532b3da46a2a003f7efac83333c1bf3

See more details on using hashes here.

File details

Details for the file nlplot-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: nlplot-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 967.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for nlplot-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fcdc1e133fc88ae335978e9bfb640df489ac062912b8bc5d851b410176959484
MD5 8a55d26531d79d1d4143556a1bc2c978
BLAKE2b-256 bd23d4eebbad1ca8203f3d2279f98fb72dc699659d90b2de8f63ce6eaf7493b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page