openlawdata_soc_ratchakitcha
收藏openlawdata-bigquery 数据集概述
数据集来源
- 本项目是 Open Law Data Thailand 项目数据集的镜像。
- 原始数据集托管于 HuggingFace: https://huggingface.co/datasets/open-law-data-thailand。
- 本项目将数据同步至 Google BigQuery 以提供便捷的查询功能。
数据访问与平台
- 数据集在 Google BigQuery 上公开且免费访问。
- 用户可使用 BigQuery Sandbox 通过网页浏览器免费分析数据,仅需 Google 账户,无需安装额外软件或绑定信用卡。
- BigQuery 数据集地址:
sourceinth.openlawdata_soc_ratchakitcha。
数据表结构
数据集包含以下两个表:
| 表名 | 描述 | 数据量(行) |
|---|---|---|
meta |
文档元数据(标题、发布日期、类别、卷、部分) | 约 136 万 |
ocr_iapp |
文档 OCR 结果(完整文本,Markdown 格式) | 约 30 万 |
数据表模式(Schema)
两个表具有相同的结构:
| 列名 | 类型 | 描述 |
|---|---|---|
content |
JSON | 文档主要内容数据 |
filename |
STRING | 源文件名 |
line_number |
INT64 | 源文件中的行号 |
publish_month |
DATE | 发布月份(用于分区) |
file_commit |
STRING | 源文件的 Git 提交哈希值 |
使用示例
以下为在 BigQuery 中查询数据的示例:
1. 统计每年公告数量
sql
SELECT
EXTRACT(YEAR FROM publish_month) AS year,
COUNT(*) AS articles
FROM sourceinth.openlawdata_soc_ratchakitcha.meta
GROUP BY year
ORDER BY year DESC
LIMIT 10
2. 查找 2024 年颁布的法律(พระราชบัญญัติ)
sql
SELECT
JSON_VALUE(content, $.doctitle) AS title,
JSON_VALUE(content, $.publishDate) AS publish_date
FROM sourceinth.openlawdata_soc_ratchakitcha.meta
WHERE JSON_VALUE(content, $.doctitle) LIKE %พระราชบัญญัติ%
AND publish_month >= 2024-01-01
LIMIT 10
3. 在 OCR 文本中搜索特定内容
sql
SELECT
JSON_VALUE(content, $.pdf_file) AS pdf_file,
SUBSTR(JSON_VALUE(content, $.data.ocr_results[0].markdown_output), 1, 500) AS text_preview
FROM sourceinth.openlawdata_soc_ratchakitcha.ocr_iapp
WHERE JSON_VALUE(content, $.data.ocr_results[0].markdown_output) LIKE %สมรส%
AND publish_month >= 2024-01-01
ORDER BY publish_month DESC
LIMIT 10
数据同步与维护
- 数据通过 GitHub Actions 每日自动从 HuggingFace 同步至 BigQuery。
- 技术栈:Bun, TypeScript, @google-cloud/bigquery。




