Knowledge Graph Creator — Example for Mark Watson's book "Practical Artificial Intelligence With Java"
Book URI: https://leanpub.com/javaai
You can read my book for free online at: https://leanpub.com/javaai/read
This example automatically generates RDF knowledge graph data from plain-text input. It uses named entity recognition (from the ner_dbpedia library) and Apache OpenNLP to extract people, places, and organizations from text, then emits RDF triples that link them via semantic relationships. The output is a deduplicated RDF file suitable for loading into a triplestore or the Semantic Web example.
- Java 11+
- Maven 3.6+
- You must build and install the
ner_dbpediaproject first (it is a local Maven dependency):
cd ../ner_dbpedia
make install# Build, run, and deduplicate output
make create_data_and_remove_duplicates
# Or step by step
mvn install -DskipTest -Dmaven.test.skip=true -q
mvn test -qThe output file output.rdf contains the generated knowledge graph.
| Artifact | Purpose |
|---|---|
com.markwatson:nerdbpedia |
Named entity recognition + DBPedia linking (local) |
org.apache.opennlp:opennlp-tools |
NLP sentence detection and tokenization |
This example is released using the Apache 2 license.
Copyright 2022-2026 Mark Watson. All rights reserved.
You are free to share and adapt this content, with attribution.