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

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

Uploaded Python 2 Python 3

Supported by

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