Find connection between any two wikipedia topics
Project description
pywikigraph
pywikigraph helps you determine the relationship between any two wikipedia articles, bold or italic terms. It tells you how closely they are connected to other (degree of separation) and also the exact shortest paths between them. You have the option to specify whether you want to use a directed graph or an undirected graph.
To learn more about this project and/or its use cases, please take a look at this blog.
How to install the package:
pip install pywikigraph
How to get the data:
The first time you use the package, data will be automatically downloaded in your specified path. In case, you want to download the data manually. There are two files that needs to be downloaded:
How to use the package:
>>> from pywikigraph import WikiGraph
>>> wg = WikiGraph(path_to_data)
Here path_to_data refers to the path you want the data to be downloaded or the path containing the files the index.pkl and wikigraph_directed_csr.npz in case you manually downloaded them.
To find the degree of separation and the shortest paths between two inputs - Backpropagation and Data Science:
>>> paths = wg.get_shortest_paths_info('Backpropagation', 'Data Science')
>>> paths
(2, 1, [['backpropagation', 'machine learning', 'data science']])
- First element of tuple indicates degree of separation
- Second element of tuple indicates number of shortest paths
- Third element of tuple is a list of exact paths
If you only care about the number of paths, then you can pass argument no_paths and the resulting tuple will just have a None for the paths element.
>>> paths_info = wg.get_shortest_paths_info('Backpropagation', 'Data Science', no_paths=True)
>>> paths_info
(2, 1, None)
If you don't care about directionality of the connections, then you can use set directed argument to False:
>>> paths_info = wg.get_shortest_paths_info('Backpropagation', 'Data Science', directed=False)
>>> paths_info
(2,
5,
[['backpropagation', 'deep learning', 'data science'],
['backpropagation', 'dimensionality reduction', 'data science'],
['backpropagation', 'glossary of artificial intelligence', 'data science'],
['backpropagation', 'machine learning', 'data science'],
['backpropagation', 'tensorflow', 'data science']])
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywikigraph-0.0.1.tar.gz.
File metadata
- Download URL: pywikigraph-0.0.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b004a29ee27f88408c2a4f0bcdca46d09e601ae113ac55763b5b6a08c17e5b0a
|
|
| MD5 |
f9e8530b344aaca58f6e83e21edba4bc
|
|
| BLAKE2b-256 |
6198bb0fd7723fa168f0e425b1f7a0d5baa802152191b710f540a99ed5af0a94
|
File details
Details for the file pywikigraph-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pywikigraph-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea440639519b0931873d194ac897b9f4e77948fa8e5384a7a36c944c24b1942
|
|
| MD5 |
c3bc70ddf887fa98b93d8a018f62570d
|
|
| BLAKE2b-256 |
8f9de4dc7369f4ce79291eaff0f56b511e7d13864ab682392569d5b247ad9104
|