sclass Text { S title; new L lines; } static L loadPoems() { new L texts; L snippets = listSnippetsOfType(48); // "Natural Language" for (Snippet sn : snippets) pcall { if (parseSnippetID(sn.id) < 1003000) break; texts.addAll(loadPoems(sn.id)); } print("Got " + n(l(texts), "text") + " (" + structure(collect(texts, "title")) + ")"); ret texts; } static L loadPoems(S snippetID) { new L texts; L lines = toLinesFullTrim(loadSnippet(snippetID)); int i = 0; while (i < l(lines)) { new Text text; // title if (i+1 < l(lines) && lines.get(i+1).startsWith("-")) { text.title = lines.get(i); i += 2; } else text.title = ""; // text while (i < l(lines) && (i+1 >= l(lines) || !lines.get(i+1).startsWith("-"))) text.lines.add(lines.get(i++)); texts.add(text); } ret texts; }