• Stars
    star
    575
  • Rank 77,055 (Top 2 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Graph Data Science: an abstraction layer in Python for building knowledge graphs, integrated with popular graph libraries – atop Pandas, NetworkX, RAPIDS, RDFlib, pySHACL, PyVis, morph-kgc, pslpython, pyarrow, etc.

kglab

DOI Licence Repo size GitHub commit activity Checked with mypy security: bandit CI downloads sponsor

Welcome to Graph Data Science: https://derwen.ai/docs/kgl/

The kglab library provides a simple abstraction layer in Python 3.7+ for building knowledge graphs, leveraging Pandas, NetworkX, RAPIDS, RDFLib, Morph-KGC, pythonPSL, and many more.

SPECIAL REQUEST:
Which features would you like in an open source Python library for building knowledge graphs?
Please add your suggestions through this survey:
https://forms.gle/FMHgtmxHYWocprMn6
This will help us prioritize the kglab roadmap.

Reviews

@kaaloo:

"Feels like it's a Hugging Face for graphs! 🀯"

Getting Started

See the "Getting Started" section of the online documentation.

Using kglab as a library for your Python project

We recommend installing from PyPi or conda:

pip

python3 -m pip install kglab

pipenv

pipenv install kglab

conda

conda env create -n kglab
conda activate kglab
pip install kglab

Or, install from source:

If you work directly from this Git repo, be sure to install the dependencies:

pip

python3 -m pip install -U pip wheel
python3 -m pip install -r requirements.txt

pipenv

pipenv install --dev

Alternatively, to install dependencies using conda:

conda env create -f environment.yml --force
conda activate kglab

Sample Code

Then to run some simple uses of this library:

import kglab

# create a KnowledgeGraph object
kg = kglab.KnowledgeGraph()

# load RDF from a URL
kg.load_rdf("http://bigasterisk.com/foaf.rdf", format="xml")

# measure the graph
measure = kglab.Measure()
measure.measure_graph(kg)

print("edges: {}\n".format(measure.get_edge_count()))
print("nodes: {}\n".format(measure.get_node_count()))

# serialize as a string in "Turtle" TTL format
ttl = kg.save_rdf_text()
print(ttl)

See the tutorial notebooks in the examples subdirectory for sample code and patterns to use in integrating kglab with other graph libraries in Python: https://derwen.ai/docs/kgl/tutorial/

WARNING when installing in an existing environment:
Installing a new package in an existing environment may reveal
or create version conflicts. See the kglab requirements
in requirements.txt before you do. For example, there are
known version conflicts regarding NumPy (>= 1.19.4) and TensorFlow 2+ (~-1.19.2)

Using Docker

For a simple approach to running the tutorials, see use of docker compose: https://derwen.ai/docs/kgl/tutorial/#use-docker-compose

Also, container images for each release are available on DockerHub: https://hub.docker.com/repository/docker/derwenai/kglab

To build a container image and run it for the tutorials:

docker build --pull --rm -f "docker/Dockerfile" -t kglab:latest .
docker run -p 8888:8888 -it kglab

To build and run a container image for testing:

docker build --pull --rm -f "docker/testsuite.Dockerfile" -t kglabtest:latest .
docker run --rm -it kglabtest
Build Instructions Note: unless you are contributing code and updates, in most use cases won't need to build this package locally.

Instead, simply install from PyPi or use Conda.

To set up the build environment locally, see the "Build Instructions" section of the online documentation.

Semantic Versioning

Before kglab reaches release v1.0.0 the types and classes may undergo substantial changes and the project is not guaranteed to have a consistent API.

Even so, we'll try to minimize breaking changes. We'll also be sure to provide careful notes.

See: changelog.txt

Contributing Code

We welcome people getting involved as contributors to this open source project!

For detailed instructions please see: CONTRIBUTING.md

License and Copyright

Source code for kglab plus its logo, documentation, and examples have an MIT license which is succinct and simplifies use in commercial applications.

All materials herein are Copyright Β© 2020-2023 Derwen, Inc.

Attribution Please use the following BibTeX entry for citing **kglab** if you use it in your research or software. Citations are helpful for the continued development and maintenance of this library.
@software{kglab,
  author = {Paco Nathan},
  title = {{kglab: a simple abstraction layer in Python for building knowledge graphs}},
  year = 2020,
  publisher = {Derwen},
  doi = {10.5281/zenodo.6360664},
  url = {https://github.com/DerwenAI/kglab}
}

illustration of a knowledge graph, plus laboratory glassware

Kudos

Many thanks to our open source sponsors; and to our contributors: @ceteri, @dvsrepo, @Ankush-Chander, @louisguitton, @tomaarsen, @Mec-iS, @jake-aft, @Tpt, @ArenasGuerreroJulian, @fils, @cutterkom, @RishiKumarRay, @gauravjaglan, @pebbie, @CatChenal, @dmoore247, plus general support from Derwen, Inc.; the Knowledge Graph Conference and Connected Data World; plus an even larger scope of use cases represented by their communities; Kubuntu Focus, the RAPIDS team @ NVIDIA, Gradient Flow, and Manning Publications.

kglab contributors

Star History

Star History Chart

More Repositories

1

pytextrank

Python implementation of TextRank algorithms ("textgraphs") for phrase extraction
Python
2,131
star
2

ray_tutorial

An introductory tutorial about leveraging Ray core features for distributed patterns.
Jupyter Notebook
77
star
3

strwythura

How to construct knowledge graphs from unstructured data sources
Jupyter Notebook
68
star
4

rllib_tutorials

RLlib tutorials
Jupyter Notebook
64
star
5

a41124835ed0

Course materials for "Get Started with NLP in Python"
Jupyter Notebook
62
star
6

exsto

Analyze the structure and dynamics of an open source project's developer community, using graph algorithms, etc.
Python
57
star
7

gym_example

An example implementation of an OpenAI Gym environment used for a Ray RLlib tutorial
Python
34
star
8

mkrefs

MkDocs plugin to generate semantic reference Markdown pages from a knowledge graph
Python
33
star
9

disparity_filter

Implements a disparity filter in Python, based on graphs in NetworkX, to extract the multiscale backbone of a complex weighted network (Serrano, et al., 2009)
Python
31
star
10

spaCy_tuTorial

A brief tutorial for spaCy 2.x, which runs on Google Colab
Jupyter Notebook
25
star
11

ERKG

Demonstrate integration of Senzing and Neo4j to construct an Entity Resolved Knowledge Graph
21
star
12

ibm_dsc_articles

Notebooks and other code+data supporting articles for the IBM Data Science Community
Jupyter Notebook
21
star
13

textgraphs

TextGraphs + LLMs + graph ML for entity extraction, linking, ranking, and constructing a lemma graph
Python
17
star
14

arxiv-trends

Analyze trends in articles published on arXiv
Jupyter Notebook
15
star
15

pynock

A proposed standard `NOCK` for a Parquet format that supports efficient distributed serialization of multiple kinds of graph technologies
Python
15
star
16

kuzu-rdflib

An integration of KΓΉzuDB and RDFlib.
Python
9
star
17

ray_base

Docker build for a base image for running Ray on K8s on Azure
Jupyter Notebook
5
star
18

rcc_book

Rich Search and Discovery for Research Datasets: Building the next generation of scholarly infrastructure
Python
3
star
19

cyphigh

Support for distributed processing of openCypher in Python.
Python
2
star
20

gym_projectile

A simple implementation of an OpenAI Gym environment, which simulates a projectile trajectory
Python
2
star
21

goedwig

A generic query engine for graph data, based on abstract syntax trees as input.
Python
1
star
22

ibm_dsc_geo

Examples of geospatial work in Python on Ubuntu 18.04 LTS
Jupyter Notebook
1
star
23

rayCy_example

Demo / test harness for a code conflict in Ray actors with Cython-based classes
Python
1
star
24

gym_trivial

A minimal implementation of an OpenAI Gym environment, which simulates an `AND` gate
Python
1
star