Add corpus metadata to Croissant
Browse files- croissant.json +263 -7
- util/croissant.py +99 -4
croissant.json
CHANGED
@@ -49,7 +49,7 @@
|
|
49 |
"description": "ELCC is a collection of emergent language corpora with accompanying metadata and analyses.",
|
50 |
"conformsTo": "http://mlcommons.org/croissant/1.0",
|
51 |
"citeAs": "@misc{boldt2024elcc,\n title = \"{ELCC}: the Emergent Language Corpus Collection\",\n author = \"Brendon Boldt and David Mortensen\",\n year = 2024,\n url = \"https://huggingface.co/datasets/bboldt/elcc\",\n}",
|
52 |
-
"datePublished": "2024-06-13
|
53 |
"keywords": [
|
54 |
"emergent communication",
|
55 |
"emergent language",
|
@@ -65,7 +65,7 @@
|
|
65 |
"name": "repo",
|
66 |
"contentUrl": "https://huggingface.co/datasets/bboldt/elcc/",
|
67 |
"encodingFormat": "git+https",
|
68 |
-
"sha256": "
|
69 |
},
|
70 |
{
|
71 |
"@type": "cr:FileSet",
|
@@ -87,6 +87,26 @@
|
|
87 |
"encodingFormat": "text/plain",
|
88 |
"includes": "systems/*/system.json"
|
89 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
{
|
91 |
"@type": "cr:FileObject",
|
92 |
"@id": "systems/babyai-sr/data/GoToObj/corpus.json",
|
@@ -829,11 +849,6 @@
|
|
829 |
"@id": "system-metadata-raw/path",
|
830 |
"name": "path",
|
831 |
"dataType": "sc:Text",
|
832 |
-
"references": {
|
833 |
-
"field": {
|
834 |
-
"@id": "system-metadata/path"
|
835 |
-
}
|
836 |
-
},
|
837 |
"source": {
|
838 |
"fileSet": {
|
839 |
"@id": "system-metadata-files-raw"
|
@@ -1076,6 +1091,247 @@
|
|
1076 |
}
|
1077 |
]
|
1078 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1079 |
{
|
1080 |
"@type": "cr:RecordSet",
|
1081 |
"@id": "babyai-sr/GoToObj",
|
|
|
49 |
"description": "ELCC is a collection of emergent language corpora with accompanying metadata and analyses.",
|
50 |
"conformsTo": "http://mlcommons.org/croissant/1.0",
|
51 |
"citeAs": "@misc{boldt2024elcc,\n title = \"{ELCC}: the Emergent Language Corpus Collection\",\n author = \"Brendon Boldt and David Mortensen\",\n year = 2024,\n url = \"https://huggingface.co/datasets/bboldt/elcc\",\n}",
|
52 |
+
"datePublished": "2024-06-13 07:19:21.844134+00:00",
|
53 |
"keywords": [
|
54 |
"emergent communication",
|
55 |
"emergent language",
|
|
|
65 |
"name": "repo",
|
66 |
"contentUrl": "https://huggingface.co/datasets/bboldt/elcc/",
|
67 |
"encodingFormat": "git+https",
|
68 |
+
"sha256": "main"
|
69 |
},
|
70 |
{
|
71 |
"@type": "cr:FileSet",
|
|
|
87 |
"encodingFormat": "text/plain",
|
88 |
"includes": "systems/*/system.json"
|
89 |
},
|
90 |
+
{
|
91 |
+
"@type": "cr:FileSet",
|
92 |
+
"@id": "corpus-metadata-files",
|
93 |
+
"name": "corpus-metadata-files",
|
94 |
+
"containedIn": {
|
95 |
+
"@id": "repo"
|
96 |
+
},
|
97 |
+
"encodingFormat": "application/json",
|
98 |
+
"includes": "systems/*/data/*/metadata.json"
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"@type": "cr:FileSet",
|
102 |
+
"@id": "corpus-metadata-files-raw",
|
103 |
+
"name": "corpus-metadata-files-raw",
|
104 |
+
"containedIn": {
|
105 |
+
"@id": "repo"
|
106 |
+
},
|
107 |
+
"encodingFormat": "text/plain",
|
108 |
+
"includes": "systems/*/data/*/metadata.json"
|
109 |
+
},
|
110 |
{
|
111 |
"@type": "cr:FileObject",
|
112 |
"@id": "systems/babyai-sr/data/GoToObj/corpus.json",
|
|
|
849 |
"@id": "system-metadata-raw/path",
|
850 |
"name": "path",
|
851 |
"dataType": "sc:Text",
|
|
|
|
|
|
|
|
|
|
|
852 |
"source": {
|
853 |
"fileSet": {
|
854 |
"@id": "system-metadata-files-raw"
|
|
|
1091 |
}
|
1092 |
]
|
1093 |
},
|
1094 |
+
{
|
1095 |
+
"@type": "cr:RecordSet",
|
1096 |
+
"@id": "corpus-metadata-raw",
|
1097 |
+
"name": "corpus-metadata-raw",
|
1098 |
+
"field": [
|
1099 |
+
{
|
1100 |
+
"@type": "cr:Field",
|
1101 |
+
"@id": "corpus-metadata-raw/path",
|
1102 |
+
"name": "path",
|
1103 |
+
"dataType": "sc:Text",
|
1104 |
+
"source": {
|
1105 |
+
"fileSet": {
|
1106 |
+
"@id": "corpus-metadata-files-raw"
|
1107 |
+
},
|
1108 |
+
"extract": {
|
1109 |
+
"fileProperty": "fullpath"
|
1110 |
+
}
|
1111 |
+
}
|
1112 |
+
},
|
1113 |
+
{
|
1114 |
+
"@type": "cr:Field",
|
1115 |
+
"@id": "corpus-metadata-raw/raw",
|
1116 |
+
"name": "raw",
|
1117 |
+
"dataType": "sc:Text",
|
1118 |
+
"source": {
|
1119 |
+
"fileSet": {
|
1120 |
+
"@id": "corpus-metadata-files-raw"
|
1121 |
+
},
|
1122 |
+
"extract": {
|
1123 |
+
"fileProperty": "content"
|
1124 |
+
}
|
1125 |
+
}
|
1126 |
+
}
|
1127 |
+
]
|
1128 |
+
},
|
1129 |
+
{
|
1130 |
+
"@type": "cr:RecordSet",
|
1131 |
+
"@id": "corpus-metadata",
|
1132 |
+
"name": "corpus-metadata",
|
1133 |
+
"field": [
|
1134 |
+
{
|
1135 |
+
"@type": "cr:Field",
|
1136 |
+
"@id": "corpus-metadata/path",
|
1137 |
+
"name": "path",
|
1138 |
+
"dataType": "sc:Text",
|
1139 |
+
"source": {
|
1140 |
+
"fileSet": {
|
1141 |
+
"@id": "corpus-metadata-files"
|
1142 |
+
},
|
1143 |
+
"extract": {
|
1144 |
+
"fileProperty": "fullpath"
|
1145 |
+
},
|
1146 |
+
"transform": {
|
1147 |
+
"replace": "a"
|
1148 |
+
}
|
1149 |
+
}
|
1150 |
+
},
|
1151 |
+
{
|
1152 |
+
"@type": "cr:Field",
|
1153 |
+
"@id": "corpus-metadata/metrics.analysis.token_count",
|
1154 |
+
"name": "metrics.analysis.token_count",
|
1155 |
+
"dataType": "sc:Integer",
|
1156 |
+
"source": {
|
1157 |
+
"fileSet": {
|
1158 |
+
"@id": "corpus-metadata-files"
|
1159 |
+
},
|
1160 |
+
"extract": {
|
1161 |
+
"jsonPath": "$.metrics.analysis[\"Token Count\"]"
|
1162 |
+
}
|
1163 |
+
}
|
1164 |
+
},
|
1165 |
+
{
|
1166 |
+
"@type": "cr:Field",
|
1167 |
+
"@id": "corpus-metadata/metrics.analysis.line_count",
|
1168 |
+
"name": "metrics.analysis.line_count",
|
1169 |
+
"dataType": "sc:Integer",
|
1170 |
+
"source": {
|
1171 |
+
"fileSet": {
|
1172 |
+
"@id": "corpus-metadata-files"
|
1173 |
+
},
|
1174 |
+
"extract": {
|
1175 |
+
"jsonPath": "$.metrics.analysis[\"Line Count\"]"
|
1176 |
+
}
|
1177 |
+
}
|
1178 |
+
},
|
1179 |
+
{
|
1180 |
+
"@type": "cr:Field",
|
1181 |
+
"@id": "corpus-metadata/metrics.analysis.tokens_per_line",
|
1182 |
+
"name": "metrics.analysis.tokens_per_line",
|
1183 |
+
"dataType": "sc:Float",
|
1184 |
+
"source": {
|
1185 |
+
"fileSet": {
|
1186 |
+
"@id": "corpus-metadata-files"
|
1187 |
+
},
|
1188 |
+
"extract": {
|
1189 |
+
"jsonPath": "$.metrics.analysis[\"Tokens per Line\"]"
|
1190 |
+
}
|
1191 |
+
}
|
1192 |
+
},
|
1193 |
+
{
|
1194 |
+
"@type": "cr:Field",
|
1195 |
+
"@id": "corpus-metadata/metrics.analysis.tokens_per_line_sd",
|
1196 |
+
"name": "metrics.analysis.tokens_per_line_sd",
|
1197 |
+
"dataType": "sc:Float",
|
1198 |
+
"source": {
|
1199 |
+
"fileSet": {
|
1200 |
+
"@id": "corpus-metadata-files"
|
1201 |
+
},
|
1202 |
+
"extract": {
|
1203 |
+
"jsonPath": "$.metrics.analysis[\"Tokens per Line SD\"]"
|
1204 |
+
}
|
1205 |
+
}
|
1206 |
+
},
|
1207 |
+
{
|
1208 |
+
"@type": "cr:Field",
|
1209 |
+
"@id": "corpus-metadata/metrics.analysis.unique_tokens",
|
1210 |
+
"name": "metrics.analysis.unique_tokens",
|
1211 |
+
"dataType": "sc:Integer",
|
1212 |
+
"source": {
|
1213 |
+
"fileSet": {
|
1214 |
+
"@id": "corpus-metadata-files"
|
1215 |
+
},
|
1216 |
+
"extract": {
|
1217 |
+
"jsonPath": "$.metrics.analysis[\"Unique Tokens\"]"
|
1218 |
+
}
|
1219 |
+
}
|
1220 |
+
},
|
1221 |
+
{
|
1222 |
+
"@type": "cr:Field",
|
1223 |
+
"@id": "corpus-metadata/metrics.analysis.unique_lines",
|
1224 |
+
"name": "metrics.analysis.unique_lines",
|
1225 |
+
"dataType": "sc:Integer",
|
1226 |
+
"source": {
|
1227 |
+
"fileSet": {
|
1228 |
+
"@id": "corpus-metadata-files"
|
1229 |
+
},
|
1230 |
+
"extract": {
|
1231 |
+
"jsonPath": "$.metrics.analysis[\"Unique Lines\"]"
|
1232 |
+
}
|
1233 |
+
}
|
1234 |
+
},
|
1235 |
+
{
|
1236 |
+
"@type": "cr:Field",
|
1237 |
+
"@id": "corpus-metadata/metrics.analysis.1-gram_entropy",
|
1238 |
+
"name": "metrics.analysis.1-gram_entropy",
|
1239 |
+
"dataType": "sc:Float",
|
1240 |
+
"source": {
|
1241 |
+
"fileSet": {
|
1242 |
+
"@id": "corpus-metadata-files"
|
1243 |
+
},
|
1244 |
+
"extract": {
|
1245 |
+
"jsonPath": "$.metrics.analysis[\"1-gram Entropy\"]"
|
1246 |
+
}
|
1247 |
+
}
|
1248 |
+
},
|
1249 |
+
{
|
1250 |
+
"@type": "cr:Field",
|
1251 |
+
"@id": "corpus-metadata/metrics.analysis.1-gram_normalized_entropy",
|
1252 |
+
"name": "metrics.analysis.1-gram_normalized_entropy",
|
1253 |
+
"dataType": "sc:Float",
|
1254 |
+
"source": {
|
1255 |
+
"fileSet": {
|
1256 |
+
"@id": "corpus-metadata-files"
|
1257 |
+
},
|
1258 |
+
"extract": {
|
1259 |
+
"jsonPath": "$.metrics.analysis[\"1-gram Normalized Entropy\"]"
|
1260 |
+
}
|
1261 |
+
}
|
1262 |
+
},
|
1263 |
+
{
|
1264 |
+
"@type": "cr:Field",
|
1265 |
+
"@id": "corpus-metadata/metrics.analysis.2-gram_entropy",
|
1266 |
+
"name": "metrics.analysis.2-gram_entropy",
|
1267 |
+
"dataType": "sc:Float",
|
1268 |
+
"source": {
|
1269 |
+
"fileSet": {
|
1270 |
+
"@id": "corpus-metadata-files"
|
1271 |
+
},
|
1272 |
+
"extract": {
|
1273 |
+
"jsonPath": "$.metrics.analysis[\"2-gram Entropy\"]"
|
1274 |
+
}
|
1275 |
+
}
|
1276 |
+
},
|
1277 |
+
{
|
1278 |
+
"@type": "cr:Field",
|
1279 |
+
"@id": "corpus-metadata/metrics.analysis.2-gram_conditional_entropy",
|
1280 |
+
"name": "metrics.analysis.2-gram_conditional_entropy",
|
1281 |
+
"dataType": "sc:Float",
|
1282 |
+
"source": {
|
1283 |
+
"fileSet": {
|
1284 |
+
"@id": "corpus-metadata-files"
|
1285 |
+
},
|
1286 |
+
"extract": {
|
1287 |
+
"jsonPath": "$.metrics.analysis[\"2-gram Conditional Entropy\"]"
|
1288 |
+
}
|
1289 |
+
}
|
1290 |
+
},
|
1291 |
+
{
|
1292 |
+
"@type": "cr:Field",
|
1293 |
+
"@id": "corpus-metadata/metrics.analysis.entropy_per_line",
|
1294 |
+
"name": "metrics.analysis.entropy_per_line",
|
1295 |
+
"dataType": "sc:Float",
|
1296 |
+
"source": {
|
1297 |
+
"fileSet": {
|
1298 |
+
"@id": "corpus-metadata-files"
|
1299 |
+
},
|
1300 |
+
"extract": {
|
1301 |
+
"jsonPath": "$.metrics.analysis[\"Entropy per Line\"]"
|
1302 |
+
}
|
1303 |
+
}
|
1304 |
+
},
|
1305 |
+
{
|
1306 |
+
"@type": "cr:Field",
|
1307 |
+
"@id": "corpus-metadata/metrics.analysis.eos_token_present",
|
1308 |
+
"name": "metrics.analysis.eos_token_present",
|
1309 |
+
"dataType": "sc:Integer",
|
1310 |
+
"source": {
|
1311 |
+
"fileSet": {
|
1312 |
+
"@id": "corpus-metadata-files"
|
1313 |
+
},
|
1314 |
+
"extract": {
|
1315 |
+
"jsonPath": "$.metrics.analysis[\"EoS Token Present\"]"
|
1316 |
+
}
|
1317 |
+
}
|
1318 |
+
},
|
1319 |
+
{
|
1320 |
+
"@type": "cr:Field",
|
1321 |
+
"@id": "corpus-metadata/metrics.analysis.eos_padding",
|
1322 |
+
"name": "metrics.analysis.eos_padding",
|
1323 |
+
"dataType": "sc:Integer",
|
1324 |
+
"source": {
|
1325 |
+
"fileSet": {
|
1326 |
+
"@id": "corpus-metadata-files"
|
1327 |
+
},
|
1328 |
+
"extract": {
|
1329 |
+
"jsonPath": "$.metrics.analysis[\"EoS Padding\"]"
|
1330 |
+
}
|
1331 |
+
}
|
1332 |
+
}
|
1333 |
+
]
|
1334 |
+
},
|
1335 |
{
|
1336 |
"@type": "cr:RecordSet",
|
1337 |
"@id": "babyai-sr/GoToObj",
|
util/croissant.py
CHANGED
@@ -17,8 +17,7 @@ _distribution: list[mlc.FileObject | mlc.FileSet] = [
|
|
17 |
name="repo",
|
18 |
content_url="https://huggingface.co/datasets/bboldt/elcc/",
|
19 |
encoding_format="git+https",
|
20 |
-
|
21 |
-
sha256="b3c660db198ddca4cf1de63a4dbb0ecb573d28a3",
|
22 |
),
|
23 |
mlc.FileSet(
|
24 |
id="system-metadata-files",
|
@@ -34,6 +33,20 @@ _distribution: list[mlc.FileObject | mlc.FileSet] = [
|
|
34 |
includes=["systems/*/system.json"],
|
35 |
encoding_format="text/plain",
|
36 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
]
|
38 |
|
39 |
_metadata = mlc.Metadata(
|
@@ -196,9 +209,89 @@ def insert_system_md(metadata: mlc.Metadata) -> None:
|
|
196 |
)
|
197 |
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
@functools.cache
|
200 |
def get_metadata() -> mlc.Metadata:
|
201 |
insert_system_md(_metadata)
|
|
|
202 |
insert_corpora(_metadata)
|
203 |
return _metadata
|
204 |
|
@@ -215,12 +308,14 @@ def save_metadata() -> None:
|
|
215 |
def test() -> None:
|
216 |
dataset = mlc.Dataset(jsonld="croissant.json")
|
217 |
# records = dataset.records(record_set="babyai-sr/GoToObj")
|
218 |
-
records = dataset.records(record_set="system-metadata")
|
|
|
|
|
219 |
|
220 |
for i, x in enumerate(records):
|
221 |
print(i, x)
|
222 |
if i > 10:
|
223 |
-
|
224 |
pass
|
225 |
|
226 |
|
|
|
17 |
name="repo",
|
18 |
content_url="https://huggingface.co/datasets/bboldt/elcc/",
|
19 |
encoding_format="git+https",
|
20 |
+
sha256="main",
|
|
|
21 |
),
|
22 |
mlc.FileSet(
|
23 |
id="system-metadata-files",
|
|
|
33 |
includes=["systems/*/system.json"],
|
34 |
encoding_format="text/plain",
|
35 |
),
|
36 |
+
mlc.FileSet(
|
37 |
+
id="corpus-metadata-files",
|
38 |
+
name="corpus-metadata-files",
|
39 |
+
contained_in=["repo"],
|
40 |
+
includes=["systems/*/data/*/metadata.json"],
|
41 |
+
encoding_format="application/json",
|
42 |
+
),
|
43 |
+
mlc.FileSet(
|
44 |
+
id="corpus-metadata-files-raw",
|
45 |
+
name="corpus-metadata-files-raw",
|
46 |
+
contained_in=["repo"],
|
47 |
+
includes=["systems/*/data/*/metadata.json"],
|
48 |
+
encoding_format="text/plain",
|
49 |
+
),
|
50 |
]
|
51 |
|
52 |
_metadata = mlc.Metadata(
|
|
|
209 |
)
|
210 |
|
211 |
|
212 |
+
def insert_corpus_md(metadata: mlc.Metadata) -> None:
|
213 |
+
metadata.record_sets.append(
|
214 |
+
mlc.RecordSet(
|
215 |
+
id="corpus-metadata-raw",
|
216 |
+
name="corpus-metadata-raw",
|
217 |
+
fields=[
|
218 |
+
mlc.Field(
|
219 |
+
id="corpus-metadata-raw/path",
|
220 |
+
name="path",
|
221 |
+
data_types=[mlc.DataType.TEXT],
|
222 |
+
source=mlc.Source(
|
223 |
+
file_set="corpus-metadata-files-raw",
|
224 |
+
extract=mlc.Extract(file_property=mlc.FileProperty.fullpath),
|
225 |
+
),
|
226 |
+
# References always seem to cause conflicting read method errors.
|
227 |
+
# references={"field": {"@id": "corpus-metadata/path"}},
|
228 |
+
),
|
229 |
+
mlc.Field(
|
230 |
+
id="corpus-metadata-raw/raw",
|
231 |
+
name="raw",
|
232 |
+
data_types=[mlc.DataType.TEXT],
|
233 |
+
source=mlc.Source(
|
234 |
+
file_set="corpus-metadata-files-raw",
|
235 |
+
extract=mlc.Extract(file_property=mlc.FileProperty.content),
|
236 |
+
),
|
237 |
+
),
|
238 |
+
],
|
239 |
+
)
|
240 |
+
)
|
241 |
+
|
242 |
+
exemplar_path = "systems/nav-to-center/data/temperature_10/metadata.json"
|
243 |
+
with open(exemplar_path) as fo:
|
244 |
+
exemplar_data = json.load(fo)
|
245 |
+
fields = [
|
246 |
+
mlc.Field(
|
247 |
+
id="corpus-metadata/path",
|
248 |
+
name="path",
|
249 |
+
data_types=[mlc.DataType.TEXT],
|
250 |
+
source=mlc.Source(
|
251 |
+
file_set="corpus-metadata-files",
|
252 |
+
extract=mlc.Extract(file_property=mlc.FileProperty.fullpath),
|
253 |
+
# transforms=[mlc.Transform(regex=r"(....)")],
|
254 |
+
),
|
255 |
+
# References always seem to cause conflicting read method errors.
|
256 |
+
# references={"field": {"@id": "corpus-metadata/path"}},
|
257 |
+
),
|
258 |
+
]
|
259 |
+
items = exemplar_data["metrics"]["analysis"].items()
|
260 |
+
for k, v in items:
|
261 |
+
name = f"metrics.analysis.{k}".replace(" ", "_").lower()
|
262 |
+
if isinstance(v, int):
|
263 |
+
typ = mlc.DataType.INTEGER
|
264 |
+
elif isinstance(v, bool):
|
265 |
+
typ = mlc.DataType.BOOL
|
266 |
+
else:
|
267 |
+
typ = mlc.DataType.FLOAT
|
268 |
+
jp = f'$.metrics.analysis["{k}"]'
|
269 |
+
fields.append(
|
270 |
+
mlc.Field(
|
271 |
+
id=f"corpus-metadata/{name}",
|
272 |
+
name=name,
|
273 |
+
data_types=[typ],
|
274 |
+
source=mlc.Source(
|
275 |
+
file_set="corpus-metadata-files",
|
276 |
+
# extract=mlc.Extract(file_property=mlc.FileProperty.fullpath),
|
277 |
+
extract=mlc.Extract(json_path=jp),
|
278 |
+
),
|
279 |
+
)
|
280 |
+
)
|
281 |
+
|
282 |
+
metadata.record_sets.append(
|
283 |
+
mlc.RecordSet(
|
284 |
+
id="corpus-metadata",
|
285 |
+
name="corpus-metadata",
|
286 |
+
fields=fields,
|
287 |
+
)
|
288 |
+
)
|
289 |
+
|
290 |
+
|
291 |
@functools.cache
|
292 |
def get_metadata() -> mlc.Metadata:
|
293 |
insert_system_md(_metadata)
|
294 |
+
insert_corpus_md(_metadata)
|
295 |
insert_corpora(_metadata)
|
296 |
return _metadata
|
297 |
|
|
|
308 |
def test() -> None:
|
309 |
dataset = mlc.Dataset(jsonld="croissant.json")
|
310 |
# records = dataset.records(record_set="babyai-sr/GoToObj")
|
311 |
+
# records = dataset.records(record_set="system-metadata")
|
312 |
+
# records = dataset.records(record_set="system-metadata-raw")
|
313 |
+
records = dataset.records(record_set="corpus-metadata")
|
314 |
|
315 |
for i, x in enumerate(records):
|
316 |
print(i, x)
|
317 |
if i > 10:
|
318 |
+
break
|
319 |
pass
|
320 |
|
321 |
|