forked from SEACrowd/seacrowd-datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kb.py
66 lines (61 loc) · 2.23 KB
/
kb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
Knowledge Base Schema
This is a very general schema that covers many information extraction-style
tasks, including:
- Named entity recognition (NER)
- Named entity disambiguation/canonicalization/normalization (NED)
- Event extraction
- Relation extraction (RE)
- Coreference resolution
This schema assumes a document with child elements (e.g., entities, relations)
and a flat hierarchy of document passages.
"""
import datasets
features = datasets.Features(
{
"id": datasets.Value("string"),
"passages": [{
"id": datasets.Value("string"),
"type": datasets.Value("string"),
"text": datasets.Sequence(datasets.Value("string")),
"offsets": datasets.Sequence([datasets.Value("int32")]),
}],
"entities": [{
"id": datasets.Value("string"),
"type": datasets.Value("string"),
"text": datasets.Sequence(datasets.Value("string")),
"offsets": datasets.Sequence([datasets.Value("int32")]),
"normalized": datasets.Sequence({
"db_name": datasets.Value("string"),
"db_id": datasets.Value("string"),
}),
}],
"events": [{
"id": datasets.Value("string"),
"type": datasets.Value("string"),
# refers to the text_bound_annotation of the trigger
"trigger": {
"text": datasets.Sequence(datasets.Value("string")),
"offsets": datasets.Sequence([datasets.Value("int32")]),
},
"arguments": datasets.Sequence({
"role": datasets.Value("string"),
"ref_id": datasets.Value("string"),
}),
}],
"coreferences": [{
"id": datasets.Value("string"),
"entity_ids": datasets.Sequence(datasets.Value("string")),
}],
"relations": [{
"id": datasets.Value("string"),
"type": datasets.Value("string"),
"arg1_id": datasets.Value("string"),
"arg2_id": datasets.Value("string"),
"normalized": datasets.Sequence({
"db_name": datasets.Value("string"),
"db_id": datasets.Value("string"),
}),
}],
}
)