我正在尝试加载包含 JSON 格式训练数据的Yummly数据。以下是单个记录的示例:
{
"id": 10259,
"cuisine": "greek",
"ingredients": [
"romaine lettuce",
"black olives",
"grape tomatoes",
"garlic",
"pepper",
"purple onion",
"seasoning",
"garbanzo beans",
"feta cheese crumbles"
]
}
这是我尝试加载这些数据
use IO;
const test_data_f: string = "/home/buddha314/datasets/yummly/test.json",
train_data_f:string = "single_recipe.json";
writeln("let's load some json, shall we?");
record Recipe {
var cuisine: string,
id: int,
ingredients: [1..1] string;
}
var f = open(train_data_f, iomode.r);
var r = f.reader();
var final : Recipe;
r.readf("%jt\n", final);
writeln(final);
我显然不会先验地知道成分的数量,所以我尝试了这条线ingredients: [1..1] string;
,但无济于事。在弄乱它之后,我无法让它工作。