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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# STEA(W-I) / STEA(Y-I) 时空实体对齐数据集构建方案
|
| 2 |
+
|
| 3 |
+
## 1. 目标与设计原则
|
| 4 |
+
|
| 5 |
+
### 1.1 目标
|
| 6 |
+
基于已有 STKGA 的 `icews_wiki` 和 `icews_yago` 纯时序数据集,为每条 triple 补充异构空间位置信息,构建时空五元组 `(head, rel, tail, time, spatial_info)`,产出两个新数据集:
|
| 7 |
+
- **STEA(W-I)**:ICEWS ↔ Wikipedia,含空间事实
|
| 8 |
+
- **STEA(Y-I)**:ICEWS ↔ YAGO,含空间事实
|
| 9 |
+
|
| 10 |
+
### 1.2 设计决策
|
| 11 |
+
|
| 12 |
+
| 决策项 | 选择 | 理由 |
|
| 13 |
+
|--------|------|------|
|
| 14 |
+
| 空间粒度 | 事件/元组级别 | 每条 triple 自带空间信息,而非套实体级静态坐标 |
|
| 15 |
+
| 空间表示 | 异构三模态 | `lat/lon` + `spatial_text` + `admin_region` 并行独立 |
|
| 16 |
+
| 无空间信息 | 跳过不填 | 不强制造假数据 |
|
| 17 |
+
| 原始数据 | 一字不改、一行不删 | 纯 JOIN 追加列,原始文件全部复用 |
|
| 18 |
+
| 命名 | STEA(W-I) / STEA(Y-I) | 与 PhyWorld-Align 论文对齐 |
|
| 19 |
+
|
| 20 |
+
### 1.3 异构空间设计
|
| 21 |
+
|
| 22 |
+
对标论文核心挑战:*"同一个实体在不同 KG 中空间记录方式截然不同——KG1 用精确 GPS,KG2 只有文本描述"*
|
| 23 |
+
|
| 24 |
+
每条 triple 的空间字段从简单的 `lat\tlon` 升级为 **三模态并行**:
|
| 25 |
+
|
| 26 |
+
```
|
| 27 |
+
head_id rel_id tail_id time_id flag lat lon spatial_text admin_region
|
| 28 |
+
6138 111 3990 135 135 41.9028 12.4964 Rome, Italy Italy/Lazio/Rome
|
| 29 |
+
6147 3 10429 204 204 office corridor
|
| 30 |
+
22665 272 11465 324 324 38.8977 -77.0365 US Capitol United States/DC
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
| 字段 | 说明 | ICEWS 端来源 | Wikipedia 端来源 | YAGO 端来源 |
|
| 34 |
+
|------|------|-------------|-----------------|-------------|
|
| 35 |
+
| `lat` | 纬度 | ICEWS Latitude | Wikidata P625 | YAGO hasLatitude |
|
| 36 |
+
| `lon` | 经度 | ICEWS Longitude | Wikidata P625 | YAGO hasLongitude |
|
| 37 |
+
| `spatial_text` | 文本位置描述 | City + Actor name | Wikidata P276 / 页面标题 | YAGO happenedIn |
|
| 38 |
+
| `admin_region` | 层级行政区域 | Country/Province/City | Wikidata P131/P17 | YAGO isLocatedIn |
|
| 39 |
+
|
| 40 |
+
**关键**:三列互不依赖,各自独立。某列没有就留空。
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## 2. 数据现状
|
| 45 |
+
|
| 46 |
+
| | icews_wiki | icews_yago |
|
| 47 |
+
|---|---|---|
|
| 48 |
+
| KG1 实体 | 11,047 (ICEWS) | 26,863 (ICEWS) |
|
| 49 |
+
| KG1 三元组 | 3,527,881 | 4,192,555 |
|
| 50 |
+
| KG2 实体 | 15,831 (Wikipedia) | 22,555 (YAGO) |
|
| 51 |
+
| KG2 三元组 | 198,257 | 107,118 |
|
| 52 |
+
| 训练/测试对 | 1,518 / 3,540 | 5,648 / 13,176 |
|
| 53 |
+
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## 3. 三路空间数据获取
|
| 57 |
+
|
| 58 |
+
### Phase 1: Wikipedia 实体空间数据
|
| 59 |
+
|
| 60 |
+
**数据源**:Wikidata SPARQL (`query.wikidata.org/sparql`)
|
| 61 |
+
|
| 62 |
+
```sparql
|
| 63 |
+
SELECT ?enTitle ?lat ?lon ?adminLabel ?locationLabel ?countryLabel WHERE {
|
| 64 |
+
VALUES ?enTitle { "title1"@en ... }
|
| 65 |
+
?article schema:about ?item ;
|
| 66 |
+
schema:isPartOf <https://en.wikipedia.org/> ;
|
| 67 |
+
schema:name ?enTitle .
|
| 68 |
+
OPTIONAL { ?item wdt:P625 ?coord . } # GPS
|
| 69 |
+
OPTIONAL { ?item wdt:P131 ?admin . } # 行政区域
|
| 70 |
+
OPTIONAL { ?item wdt:P276 ?location . } # 所在位置
|
| 71 |
+
OPTIONAL { ?item wdt:P17 ?country . } # 国家
|
| 72 |
+
}
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
**参数**:250 实体/批,64 批,间隔 1.5s,90s 超时,3 次重试
|
| 76 |
+
|
| 77 |
+
### Phase 2: YAGO 实体空间数据
|
| 78 |
+
|
| 79 |
+
**方案 A**:YAGO SPARQL (`yago-knowledge.org/sparql`)
|
| 80 |
+
```sparql
|
| 81 |
+
SELECT ?entity ?lat ?lon ?locationName ?adminName WHERE {
|
| 82 |
+
VALUES ?entity { <http://yago-knowledge.org/resource/XXX> ... }
|
| 83 |
+
OPTIONAL { ?entity yago:hasLatitude ?lat . }
|
| 84 |
+
OPTIONAL { ?entity yago:hasLongitude ?lon . }
|
| 85 |
+
OPTIONAL { ?entity yago:isLocatedIn ?admin . }
|
| 86 |
+
OPTIONAL { ?entity yago:happenedIn ?location . }
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
**方案 B**(备选):YAGO 4.5 RDF dump 本地解析
|
| 91 |
+
|
| 92 |
+
### Phase 3: ICEWS 事件空间数据
|
| 93 |
+
|
| 94 |
+
**数据源**:哈佛 Dataverse ICEWS Coded Event Data
|
| 95 |
+
|
| 96 |
+
1. 下载 ICEWS 事件数据(`.tab`,约 2GB)
|
| 97 |
+
2. 构建 `Actor Name → Entity ID` 映射
|
| 98 |
+
3. 遍历 `triples_1`,用 `(actor, event_type, date)` 匹配原始 ICEWS 事件
|
| 99 |
+
4. 提取:`Latitude, Longitude, City, Province, Country`
|
| 100 |
+
5. 备选:若匹配率低,用 Nominatim Geocoding 补充
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## 4. 融合逻辑
|
| 105 |
+
|
| 106 |
+
```
|
| 107 |
+
对 triples_1 每条 (h, r, t, time):
|
| 108 |
+
→ 用 (h_entity_name, r_type, time_window) 搜 ICEWS 原始事件
|
| 109 |
+
→ 匹配成功: lat, lon, spatial_text(City), admin_region(Country/Province)
|
| 110 |
+
→ 匹配失败: 四列留空
|
| 111 |
+
|
| 112 |
+
对 triples_2 每条 (h, r, t, time):
|
| 113 |
+
→ 用 h_entity_id 查 Phase 1/2 结果
|
| 114 |
+
→ 有数据: lat, lon, spatial_text, admin_region
|
| 115 |
+
→ 无数据: 四列留空
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
**融合不是外部数据混合**:原始 triple 一行不改,只在末尾 JOIN 追加空间列。
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
## 5. 输出文件结构
|
| 123 |
+
|
| 124 |
+
### STEA_W-I/ 和 STEA_Y-I/ 各 12 个文件
|
| 125 |
+
|
| 126 |
+
```
|
| 127 |
+
STEA_W-I/
|
| 128 |
+
├── ent_ids_1 复用
|
| 129 |
+
├── ent_ids_2 复用
|
| 130 |
+
├── rel_ids_1 复用
|
| 131 |
+
├── rel_ids_2 复用
|
| 132 |
+
├── time_id 复用
|
| 133 |
+
├── sup_pairs 复用
|
| 134 |
+
├── ref_pairs 复用
|
| 135 |
+
├── ref_ent_ids 复用
|
| 136 |
+
├── triples_1.tsv NEW:原 5 列 + lat + lon + spatial_text + admin_region
|
| 137 |
+
├── triples_2.tsv NEW:同上
|
| 138 |
+
├── ent_locations_1.tsv NEW:实体坐标索引
|
| 139 |
+
└── ent_locations_2.tsv NEW:实体坐标索引
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
### 新增文件列结构
|
| 143 |
+
|
| 144 |
+
**triples_1.tsv / triples_2.tsv**(9 列):
|
| 145 |
+
```
|
| 146 |
+
head_id rel_id tail_id time_id flag lat lon spatial_text admin_region
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
**ent_locations_1.tsv / ent_locations_2.tsv**(6 列):
|
| 150 |
+
```
|
| 151 |
+
entity_id lat lon spatial_text admin_region source
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
## 6. 校验
|
| 157 |
+
|
| 158 |
+
| 校验项 | 规则 |
|
| 159 |
+
|--------|------|
|
| 160 |
+
| 坐标范围 | lat ∈ [-90,90], lon ∈ [-180,180] |
|
| 161 |
+
| 缺失率 | 分别统计四列在 triples_1 和 triples_2 中的填充率 |
|
| 162 |
+
| 一致性抽查 | ICEWS 端同一实体相邻时间戳坐标距离是否物理可达 |
|
| 163 |
+
| 行数不变 | `wc -l triples_1.tsv == wc -l triples_1_原文件` |
|
| 164 |
+
|
| 165 |
+
---
|
| 166 |
+
|
| 167 |
+
## 7. 执行步骤
|
| 168 |
+
|
| 169 |
+
| 步骤 | 内容 | 预估 |
|
| 170 |
+
|------|------|------|
|
| 171 |
+
| P1 | Wikidata SPARQL 查 Wikipedia 空间数据 | 15 min |
|
| 172 |
+
| P2 | YAGO SPARQL 查 YAGO 空间数据 | 15 min |
|
| 173 |
+
| P3a | 下载 ICEWS 原始事件 | 10 min |
|
| 174 |
+
| P3b | ICEWS 事件匹配提取 | 30 min |
|
| 175 |
+
| P4 | 融合生成 triples + ent_locations | 5 min |
|
| 176 |
+
| P5 | 校验 + 统计 | 5 min |
|
| 177 |
+
| P6 | 上传 Hugging Face | 10 min |
|
| 178 |
+
|
| 179 |
+
---
|
| 180 |
+
|
| 181 |
+
## 8. 发布
|
| 182 |
+
|
| 183 |
+
**仓库**:`https://huggingface.co/datasets/eduzrh/STKGA`
|
| 184 |
+
**目录**:`STEA_W-I/` 和 `STEA_Y-I/`
|
| 185 |
+
|
| 186 |
+
---
|
| 187 |
+
|
| 188 |
+
## 9. 风险应对
|
| 189 |
+
|
| 190 |
+
| 风险 | 应对 |
|
| 191 |
+
|------|------|
|
| 192 |
+
| Wikidata SPARQL 超时 | 减小批次 200,3 次重试 |
|
| 193 |
+
| YAGO SPARQL 不可用 | 改本地 RDF dump 解析 |
|
| 194 |
+
| ICEWS 下载受限 | Nominatim geocoding 替代 |
|
| 195 |
+
| ICEWS Actor 不匹配 | 模糊匹配 + 高频实体手动标注 |
|