|
|
--- |
|
|
language: |
|
|
- id |
|
|
license: cc-by-4.0 |
|
|
task_categories: |
|
|
- text-retrieval |
|
|
- question-answering |
|
|
tags: |
|
|
- legal |
|
|
- indonesian-law |
|
|
- knowledge-graph |
|
|
- sqlite |
|
|
- database |
|
|
size_categories: |
|
|
- 100K<n<1M |
|
|
--- |
|
|
|
|
|
# Indonesian Legal Regulations - SQLite Database |
|
|
|
|
|
## Dataset Description |
|
|
|
|
|
This is a SQLite database version of the Indonesian Legal Regulations Knowledge Graph dataset, optimized for easy querying and integration. |
|
|
|
|
|
### Database Statistics |
|
|
|
|
|
- **Total Regulations**: 748,558 |
|
|
- **Total Embeddings**: 748,558 |
|
|
- **Total TF-IDF Vectors**: 748,558 |
|
|
- **Database Size**: 10498.50 MB |
|
|
|
|
|
### Database Schema |
|
|
|
|
|
#### Main Tables |
|
|
|
|
|
1. **regulations** - Core regulation data with KG features |
|
|
2. **embeddings** - 1024D semantic embeddings (BLOB storage) |
|
|
3. **tfidf_vectors** - 20000D TF-IDF vectors (BLOB storage) |
|
|
4. **kg_json_data** - Knowledge Graph JSON data |
|
|
5. **regulations_fts** - Full-Text Search virtual table |
|
|
|
|
|
### Features |
|
|
|
|
|
- **Optimized Indexing**: Fast queries on common fields |
|
|
- **Full-Text Search**: FTS5 for content search |
|
|
- **Normalized Storage**: Separate tables for vectors |
|
|
- **BLOB Storage**: Efficient storage for large vectors |
|
|
- **Foreign Keys**: Referential integrity |
|
|
|
|
|
### Usage Example |
|
|
|
|
|
```python |
|
|
import sqlite3 |
|
|
import numpy as np |
|
|
from huggingface_hub import hf_hub_download |
|
|
|
|
|
# Download database |
|
|
db_path = hf_hub_download( |
|
|
repo_id="Azzindani/ID_REG_DB_2510", |
|
|
filename="id_regulations.db", |
|
|
repo_type="dataset" |
|
|
) |
|
|
|
|
|
# Connect |
|
|
conn = sqlite3.connect(db_path) |
|
|
cursor = conn.cursor() |
|
|
|
|
|
# Query regulations |
|
|
cursor.execute(""" |
|
|
SELECT global_id, content, kg_authority_score |
|
|
FROM regulations |
|
|
WHERE regulation_type = 'UU' |
|
|
ORDER BY year DESC |
|
|
LIMIT 10 |
|
|
""") |
|
|
|
|
|
for row in cursor.fetchall(): |
|
|
print(row) |
|
|
|
|
|
# Get embedding |
|
|
cursor.execute(""" |
|
|
SELECT embedding, dimension |
|
|
FROM embeddings |
|
|
WHERE global_id = ? |
|
|
""", ('some_id',)) |
|
|
|
|
|
row = cursor.fetchone() |
|
|
if row: |
|
|
embedding_blob, dim = row |
|
|
embedding = np.frombuffer(embedding_blob, dtype=np.float32) |
|
|
print(f"Embedding shape: {embedding.shape}") |
|
|
|
|
|
# Full-text search |
|
|
cursor.execute(""" |
|
|
SELECT global_id, content |
|
|
FROM regulations_fts |
|
|
WHERE regulations_fts MATCH 'pajak OR perpajakan' |
|
|
LIMIT 10 |
|
|
""") |
|
|
|
|
|
# Close |
|
|
conn.close() |
|
|
``` |
|
|
|
|
|
### Query Examples |
|
|
|
|
|
#### Find regulations by domain |
|
|
```sql |
|
|
SELECT * FROM regulations |
|
|
WHERE kg_primary_domain = 'tax' |
|
|
ORDER BY kg_authority_score DESC; |
|
|
``` |
|
|
|
|
|
#### Search content with FTS |
|
|
```sql |
|
|
SELECT * FROM regulations_fts |
|
|
WHERE regulations_fts MATCH 'undang-undang pajak'; |
|
|
``` |
|
|
|
|
|
#### Get regulation with embedding |
|
|
```sql |
|
|
SELECT r.*, e.embedding |
|
|
FROM regulations r |
|
|
JOIN embeddings e ON r.global_id = e.global_id |
|
|
WHERE r.regulation_type = 'UU' AND r.year >= 2020; |
|
|
``` |
|
|
|
|
|
#### Find highly cited regulations |
|
|
```sql |
|
|
SELECT * FROM regulations |
|
|
WHERE kg_pagerank > 0.001 |
|
|
ORDER BY kg_pagerank DESC |
|
|
LIMIT 20; |
|
|
``` |
|
|
|
|
|
### Source Dataset |
|
|
|
|
|
This database was created from: `Azzindani/ID_REG_KG_2511` |
|
|
|
|
|
### License |
|
|
|
|
|
CC-BY-4.0 |
|
|
|
|
|
### Citation |
|
|
|
|
|
```bibtex |
|
|
@dataset{indonesian_legal_db_2024, |
|
|
author = {Azzindani}, |
|
|
title = {Indonesian Legal Regulations - SQLite Database}, |
|
|
year = {2024}, |
|
|
publisher = {HuggingFace}, |
|
|
url = {https://huggingface.co/datasets/Azzindani/ID_REG_DB_2511} |
|
|
} |
|
|
``` |
|
|
|