A module to generate a graph of words
Project description
Graph of words
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:
- Split the text into sentences if required
- Slide a window across each sentence
- 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
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
Close
Hashes for graph_of_words-0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b155b58c5ef55d3f9a616584519f2e0917ab0c5aecfbf51dd4e99cac7a79770 |
|
MD5 | c12f2049445cb5ad1b374a1989942e8e |
|
BLAKE2b-256 | 0f84791839cfcecd1be64b5edbf88716f3c044b9c9be414f1b966f59e9e38e92 |