Uses 911K of libraries. Click here for Pure Java version (3878L/21K).
!7 // Text + questions from https://lingua.com/english/reading/my-day/ cmodule MyDay > DynPrintLog { start-thread { LS paragraphs = pnlStruct(paragraphsTokC([[ Text ---- First, I wake up. Then, I get dressed. I walk to school. I do not ride a bike. I do not ride the bus. I like to go to school. It rains. I do not like rain. I eat lunch. I eat a sandwich and an apple. I play outside. I like to play. I read a book. I like to read books. I walk home. I do not like walking home. My mother cooks soup for dinner. The soup is hot. Then, I go to bed. I do not like to go bed. Question 1: What happens first? 1 Get dressed 2 Wake up 3 Eat lunch 4 Walk to school Question 2: What do I like? 1 Books 2 Rain 3 Walking home 4 Going to bed Question 3: How do I go to school? 1 I ride a bike. 2 I walk. 3 I ride the bus. 4 I drive a car. Question 4: What do I eat for dinner? 1 Sandwich 2 Pie 3 Soup 4 Apple Question 5: What do I not like? 1 Going to school 2 Going to bed 3 Playing 4 Soup ]])); L<Bool> isQ = print(map(rcurry_swic("Question"), paragraphs)); int idx = print(falsesFollowedByTrues_changeIndex_assertNotNull(isQ)); LS textPart = takeFirst(paragraphs, idx); LS questionsPart = sublist(paragraphs, idx); assertTrue(isPreciseMultiDashesHeading(first(textPart))); S text = joinWithEmptyLines(dropFirst(textPart)); LS sentences = pnl(sentences(text)); for (S s : questionsPart) { LS lines = tlft(s); assertEquals(4, l(lines)); assertStartsWith(first(lines), "Question "); S q = second(lines); LS answersOnLine = regexpGroups("^1(.+)2(.+)$", third(lines)); assertNempty(answersOnLine); LS answersOnLine2 = regexpGroups("^3(.+)4(.+)$", last(lines)); assertNempty(answersOnLine2); LS answers = trimAll(concatLists(answersOnLine, answersOnLine2)); print(q); printStruct(answers); } } }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023735 |
Snippet name: | "My Day" [v1, just the parsing] |
Eternal ID of this version: | #1023735/13 |
Text MD5: | b85f531cd5a30c7a08fd54a538fefcf8 |
Transpilation MD5: | 3de40acf36b8e6aa6ac9cf7f257565bc |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-07-07 21:27:36 |
Source code size: | 2185 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 347 / 528 |
Version history: | 12 change(s) |
Referenced in: | #1023737 - "My Day" [v2, parse into fields] |