Libraryless. Click here for Pure Java version (4740L/30K).
1 | static ReadingComprehensionTest ai_parseReadingComprehensionTest_v1(S rawText, O... _) {
|
2 | optPar bool printText = true; |
3 | new ReadingComprehensionTest test; |
4 | |
5 | LS paragraphs = pnlStructIf(printText, paragraphsTokC(rawText)); |
6 | L<Bool> isQ = map(rcurry_swic("Question"), paragraphs);
|
7 | int idx = falsesFollowedByTrues_changeIndex_assertNotNull(isQ); |
8 | LS textPart = takeFirst_clone(paragraphs, idx); |
9 | LS questionsPart = sublist(paragraphs, idx); |
10 | if (isPreciseMultiDashesHeading(first(textPart))) popFirst(textPart); |
11 | test.text = joinWithEmptyLines(textPart); |
12 | test.sentences = pnlIf(printText, sentences(test.text)); |
13 | |
14 | for (S s : questionsPart) {
|
15 | LS lines = tlft(s); |
16 | assertEquals(4, l(lines)); |
17 | assertStartsWith(first(lines), "Question "); |
18 | S q = second(lines); |
19 | LS answersOnLine = regexpGroups("^1(.+)2(.+)$", third(lines));
|
20 | assertNempty(answersOnLine); |
21 | LS answersOnLine2 = regexpGroups("^3(.+)4(.+)$", last(lines));
|
22 | assertNempty(answersOnLine2); |
23 | LS answers = trimAll(concatLists(answersOnLine, answersOnLine2)); |
24 | add(test.questions, nu(ReadingComprehensionTest.Question.class, question := q, +answers)); |
25 | print(q); |
26 | printStruct(answers); |
27 | } |
28 | |
29 | ret test; |
30 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
| ID | Author/Program | Comment | Date | |
|---|---|---|---|---|
| 1379 | anonymous | Remarkable | 2019-07-09 02:34:43 | delete |
| Snippet ID: | #1023739 |
| Snippet name: | ai_parseReadingComprehensionTest_v1 |
| Eternal ID of this version: | #1023739/15 |
| Text MD5: | 3615298272e4c31e7030429809c9928f |
| Transpilation MD5: | 85737ea75d36ca51295987116d86c914 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-07-09 12:51:40 |
| Source code size: | 1241 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 753 / 942 |
| Version history: | 14 change(s) |
| Referenced in: | [show references] |