Skip to main content

A module to generate a graph of words

Project description

Graph of words

REUSE status

Create a graph of word representation from a text. Roughly based on Malliaros, F. D., & Skianis, K. (2015). Graph-Based Term Weighting for Text Categorization. 1473–1479. https://doi.org/10.1145/2808797.2808872

Example:

import graph
graph = graph.GraphOfWords(window_size=2)
graph.build_graph(
    'Roses are red. Violets are blue',
    # OR a sentences list['Roses  are  red.', 'Violets are blue'],
    remove_stopwords=False,
    workers=4
)

graph.display_graph()
graph.write_graph_edges('edges_list.txt')

Note that build_graph also accepts a list of sentences.

The following actions are performed:

  1. Split the text into sentences if required
  2. Slide a window across each sentence
  3. Add a directed graph edge form the current word to the other ones within the window, the weight being the distance between the two words

Documentation

See the documentation.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

graph_of_words-0.1-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file graph_of_words-0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: graph_of_words-0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

File hashes

Hashes for graph_of_words-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7b155b58c5ef55d3f9a616584519f2e0917ab0c5aecfbf51dd4e99cac7a79770
MD5 c12f2049445cb5ad1b374a1989942e8e
BLAKE2b-256 0f84791839cfcecd1be64b5edbf88716f3c044b9c9be414f1b966f59e9e38e92

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