Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anjola-adeuyi/bulbapedia-knowledge-graph
A Semantic Web application that builds a Knowledge Graph (KG) from Bulbapedia, similar to how DBpedia was built from Wikipedia. This project captures Pokémon data from Bulbapedia, converts it into RDF format, and provides various interfaces to access and query the knowledge graph.
https://github.com/anjola-adeuyi/bulbapedia-knowledge-graph
bulbapedia bulbapedia-parser dbpedia fuseki knowledge-graph pokedex rdf rdfs shacl shacl-shapes sparql triples triplestore wikidata
Last synced: 5 days ago
JSON representation
A Semantic Web application that builds a Knowledge Graph (KG) from Bulbapedia, similar to how DBpedia was built from Wikipedia. This project captures Pokémon data from Bulbapedia, converts it into RDF format, and provides various interfaces to access and query the knowledge graph.
- Host: GitHub
- URL: https://github.com/anjola-adeuyi/bulbapedia-knowledge-graph
- Owner: anjola-adeuyi
- Created: 2025-01-15T21:50:55.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2025-01-15T22:22:13.000Z (18 days ago)
- Last Synced: 2025-01-16T00:14:37.464Z (17 days ago)
- Topics: bulbapedia, bulbapedia-parser, dbpedia, fuseki, knowledge-graph, pokedex, rdf, rdfs, shacl, shacl-shapes, sparql, triples, triplestore, wikidata
- Language: Java
- Homepage:
- Size: 882 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bulbapedia Knowledge Graph
A Semantic Web application that builds a Knowledge Graph (KG) from Bulbapedia, similar to how DBpedia was built from Wikipedia. This project captures Pokémon data from Bulbapedia, converts it into RDF format, and provides various interfaces to access and query the knowledge graph.
## Features
### 1. Knowledge Graph Generation
- Extracts data from Bulbapedia's wiki pages using MediaWiki API
- Converts wiki content into RDF triples with schema.org alignment
- Implements proper ontology and vocabulary design
- Maintains multilingual labels (English, Japanese, Romaji)
- Includes entity linking to DBpedia and Wikidata
- Supports multiple Pokemon generations
- Processes evolution chains with type preservation### 2. Data Validation
- SHACL shapes for validating the knowledge graph structure
- Constraints on Pokémon properties (height, weight, types)
- Type hierarchy validation
- Property cardinality rules
- RDF quality checks using Jena validation### 3. Query Interface
- SPARQL endpoint (port 3330)
- Support for inference in queries:
- RDFS subclass hierarchy
- Transitive properties (owl:sameAs)
- Property inheritance
- Predefined useful queries for common operations### 4. Linked Data Interface
- Content negotiation (HTML/RDF)
- Human-readable HTML views with:
- Pokemon details
- Type information
- Evolution chains
- External links
- Machine-readable RDF views (Turtle format)
- Proper hyperlinking between resources## Prerequisites
- Java 11 or higher
- Maven
- Git
- Adequate disk space for the knowledge graph## Installation
1. Clone the repository:
```bash
git clone https://github.com/anjola-adeuyi/bulbapedia-knowledge-graph.git
cd bulbapedia-knowledge-graph
```2. Build the project:
```bash
mvn clean install
```## Running the Application
1. Start the application:
```bash
mvn exec:java -Dexec.mainClass="org.example.App"
```This will start:
- Fuseki SPARQL endpoint on port 3330
- Linked Data interface on port 33312. Verify the services are running:
```bash
# Test Fuseki
curl http://localhost:3330/pokemon/query# Test Linked Data interface
curl -H "Accept: text/turtle" http://localhost:3331/resource/0001
```## Testing The Features
## API Documentation
### 1. SPARQL Endpoint (Port 3330)
#### Using curl
```bash
# Example query to get all Pokémon names
curl -X POST \
-H "Content-Type: application/sparql-query" \
-d 'PREFIX schema:
SELECT ?name WHERE {
?s schema:name ?name
}' \
http://localhost:3330/pokemon/query
```#### Using Postman
1. Create a new POST request to `http://localhost:3330/pokemon/query`
2. Set Content-Type header to `application/sparql-query`
3. In the body, enter your SPARQL query
4. Send the request#### Example Queries
1. Get Pokémon and their types:
```sparql
PREFIX rdf:
PREFIX pokemon:
PREFIX schema:SELECT ?name ?primaryType ?secondaryType
WHERE {
?pokemon rdf:type pokemon:Pokemon ;
schema:name ?name ;
pokemon:primaryType ?primaryType .
OPTIONAL { ?pokemon pokemon:secondaryType ?secondaryType }
}
ORDER BY ?name
```2. Find evolution chains:
```sparql
PREFIX pokemon:
PREFIX schema:SELECT ?baseName ?evolvedName ?commonType
WHERE {
?base schema:name ?baseName ;
pokemon:primaryType ?commonType .
?evolved pokemon:evolvesFrom+ ?base ;
schema:name ?evolvedName ;
pokemon:primaryType ?commonType .
}
ORDER BY ?baseName ?evolvedName
```### 2. Linked Data Interface (Port 3331)
#### Browser Access
1. Visit `http://localhost:3331/resource/0001` for Bulbasaur
2. Navigate through Pokémon using the evolution chain links#### Programmatic Access
```bash
# Get RDF data (Turtle format)
curl -H "Accept: text/turtle" http://localhost:3331/resource/0001# Get HTML representation
curl -H "Accept: text/html" http://localhost:3331/resource/0001
```### 3. Validation
The application automatically validates all data against SHACL shapes. You can find the shapes in:
- `pokemon-shapes.ttl`
To manually validate:
1. Extract the shapes file
2. Use a SHACL validator (like Apache Jena SHACL)
3. Run validation against your RDF data## Project Structure
```bash
bulbapedia-knowledge-graph/
├── src/
│ └── main/
│ ├── java/
│ │ └── org/example/
│ │ ├── App.java # Main application
│ │ ├── client/ # Wiki API client
│ │ ├── inference/ # RDF inference
│ │ ├── linking/ # Entity linking
│ │ ├── parser/ # Wiki parsing
│ │ ├── rdf/ # RDF conversion
│ │ ├── server/ # Web servers
│ │ └── validation/ # SHACL validation
│ └── resources/
│ ├── static/ # Web interface
│ ├── templates/ # HTML templates
│ └── queries/ # SPARQL queries
├── pokemon.ttl # Generated KG
├── pokemon-shapes.ttl # SHACL shapes
└── pom.xml
```### Components
- **BulbapediaClient**: Handles API requests to Bulbapedia
- **WikiInfoboxParser**: Extracts structured data from wiki pages
- **PokemonRDFConverter**: Converts parsed data to RDF
- **InferenceHandler**: Implements RDFS and OWL inference
- **LinkedDataServer**: Provides web interface and content negotiation
- **PokemonFusekiServer**: Manages SPARQL endpoint### Access the interfaces
- SPARQL endpoint: http://localhost:3330/pokemon/query
- Linked Data interface: http://localhost:3331/
- Example Pokemon: http://localhost:3331/resource/0001### Validate RDF
```java
Model model = ModelFactory.createDefaultModel();
model.read("pokemon.ttl", "TURTLE");
System.out.println("Valid RDF with " + model.size() + " triples");
```## Features Implementation
The project implements all required features from the course specification:
1. Knowledge Graph Creation ✓
- Captures wiki content as RDF
- Converts infoboxes to triples
- Preserves wiki links as RDF relationships2. Multilingual Support ✓
- Labels in multiple languages
- Uses proper language tags
- Integrates Pokédex translations3. Schema Validation ✓
- SHACL shapes for validation
- Derived from wiki templates
- Consistent vocabulary usage4. External Linking ✓
- Links to DBpedia
- Links to Wikidata
- Preserves wiki page links5. SPARQL Access ✓
- Full SPARQL endpoint
- Support for complex queries
- Inference capabilities6. Linked Data Interface ✓
- Content negotiation
- HTML/RDF views
- Proper hyperlinking## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/new-feature`)
3. Commit your changes (`git commit -m 'Add some new feature'`)
4. Push to the branch (`git push origin feature/new-feature`)
5. Open a Pull Request## Acknowledgments
- Professor Antoine Zimmermann and Professor Victor Charpenay for the course structure and guidance
- Bulbapedia community for maintaining the Pokémon wiki
- DBpedia and YAGO project for inspiration