SchemaExtractor is a Python package for doing incredible stuff.
Project description
Schema Extractor
A python library for extracting and analyzing schema from knowledge graphs represented in turtle representation using multi-autonomous agents.
Features
- Extract schema components from TTL files
- Provide technical and semantic analysis
- Merge insights using different strategies
- Multiple output formats (text/JSON)
- Command-line interface
- Example script for quick start
Installation
Install this package via :
pip install SchemaExtractor
Or get the newest development version via:
pip install git+https://github.com/sensein/SchemaExtractor.git
Important
Copy the default configuration file and update the OPEN ROUTER API key. The rest can be used default.
# Copy and customize config
cp src/configuration/config.yaml my_config.yaml
Configuration
The library uses a YAML configuration file to manage settings for all agents. You have two options:
Use Configuration:
- Create your own YAML file with the same structure
- Pass it using the
--configoption - Allows customization of all agent settings
Example Configuration Structure:
openrouter:
base_url: "https://openrouter.ai/api/v1"
api_key: "your-api-key"
headers:
HTTP-Referer: "https://brainkb.org"
X-Title: "Schema Extractor MultiAutonomous Agents"
base_config:
temperature: 0.7
top_p: 0.9
presence_penalty: 0.0
frequency_penalty: 0.0
agent_configs:
executor:
name: "SPARQLExecutorAgent"
system_message: "..."
model: "openai/gpt-4o-2024-11-20"
temperature: 0.5
prompt:
name: "PromptAgent"
system_message: "..."
model: "openai/gpt-4o-2024-11-20"
temperature: 0.7
merger:
name: "MergerAgent"
system_message: "..."
model: "openai/gpt-4o-2024-11-20"
temperature: 0.6
Usage
1. Example Script (Quick Start)
python experiment/example.py --config my_config.yaml
python experiment/example.py \
--ttl-file experiment/schema.ttl \
--config my_config.yaml \
--strategy comprehensive \
--format json \
--output analysis.json
script Options:
--ttl-file: Path to TTL file (default: tests/sample.ttl)--config: Path to config YAML file (optional)--strategy: Analysis strategy (comprehensive, selective, conflict_resolution)--format: Output format (text, json)--output: Output file path (optional)
2. Command Line Interface
# Basic usage with default config
schema-extract extract data/schema.ttl
# With custom config
schema-extract extract data/schema.ttl --config my_config.yaml
# Full example with all options
schema-extract extract data/schema.ttl \
--config my_config.yaml \
--strategy comprehensive \
--format json \
--output results.json
# Show version
schema-extract version
# Show help
schema-extract --help
schema-extract extract --help
3. Python Library
from SchemaExtractor.app import SchemaExtractorApp
app = SchemaExtractorApp()
app = SchemaExtractorApp(config_file="my_config.yaml")
# Process
result = app.extract_schema(
ttl_file_path="data/schema.ttl",
merge_strategy="comprehensive",
output_format="text"
)
if result["status"] == "success":
if result.get("output"): # text format
print(result["output"])
else: # json format
print(f"Technical Analysis: {result['technical_analysis']}")
print(f"Semantic Analysis: {result['semantic_analysis']}")
print(f"Merged Analysis: {result['merged_analysis']}")
print(f"Insights: {result['insights']}")
Output Sample for experiment/sample.ttl data:
Contributing
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
License
This project is licensed under the Apache License 2.0 - see the LICENSE.txt file for details.
Authors
- Tek Raj Chhetri tekraj@mit.edu
Acknowledgments
- This work is part of the BrainKB project.
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 schemaextractor-1.0.1.tar.gz.
File metadata
- Download URL: schemaextractor-1.0.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e5c26ae82a6c82d6011d551a027108349061afe1df17f84f7ef646df3ea7459
|
|
| MD5 |
c5faca0057851ee049731122fc498b1c
|
|
| BLAKE2b-256 |
6ca9a4d77affb8b7f638f88fa9d0f97235edb3821e6903a57a1a603e43ff07fb
|
File details
Details for the file schemaextractor-1.0.1-py3-none-any.whl.
File metadata
- Download URL: schemaextractor-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c28be5963b1cc648d50b6fdfb87c793cc6a070c57ab292c04a5fb0f8b3a1133b
|
|
| MD5 |
02ff46639e94860121a5b81066218be5
|
|
| BLAKE2b-256 |
967ef939e85899e96df8fb25970e667454b3a018fa9d0ab01c237d8acd36b014
|