Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

66
LINES

< > BotCompany Repo | #1023735 // "My Day" [v1, just the parsing]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (3878L/21K).

1  
!7
2  
3  
// Text + questions from https://lingua.com/english/reading/my-day/
4  
5  
cmodule MyDay > DynPrintLog {
6  
  start-thread {
7  
    LS paragraphs = pnlStruct(paragraphsTokC([[
8  
    
9  
      Text
10  
      ----
11  
      
12  
      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.
13  
      
14  
      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.
15  
      
16  
      
17  
      Question 1:
18  
      What happens first?
19  
      1 Get dressed	2 Wake up
20  
      3 Eat lunch	4 Walk to school
21  
      
22  
      Question 2:
23  
      What do I like?
24  
      1 Books	2 Rain
25  
      3 Walking home	4 Going to bed
26  
      
27  
      Question 3:
28  
      How do I go to school?
29  
      1 I ride a bike.	2 I walk.
30  
      3 I ride the bus.	4 I drive a car.
31  
      
32  
      Question 4:
33  
      What do I eat for dinner?
34  
      1 Sandwich	2 Pie
35  
      3 Soup	4 Apple
36  
      
37  
      Question 5:
38  
      What do I not like?
39  
      1 Going to school	2 Going to bed
40  
      3 Playing	4 Soup
41  
      
42  
    ]]));
43  
    
44  
    L<Bool> isQ = print(map(rcurry_swic("Question"), paragraphs));
45  
    int idx = print(falsesFollowedByTrues_changeIndex_assertNotNull(isQ));
46  
    LS textPart = takeFirst(paragraphs, idx);
47  
    LS questionsPart = sublist(paragraphs, idx);
48  
    assertTrue(isPreciseMultiDashesHeading(first(textPart)));
49  
    S text = joinWithEmptyLines(dropFirst(textPart));
50  
    LS sentences = pnl(sentences(text));
51  
    
52  
    for (S s : questionsPart) {
53  
      LS lines = tlft(s);
54  
      assertEquals(4, l(lines));
55  
      assertStartsWith(first(lines), "Question ");
56  
      S q = second(lines);
57  
      LS answersOnLine = regexpGroups("^1(.+)2(.+)$", third(lines));
58  
      assertNempty(answersOnLine);
59  
      LS answersOnLine2 = regexpGroups("^3(.+)4(.+)$", last(lines));
60  
      assertNempty(answersOnLine2);
61  
      LS answers = trimAll(concatLists(answersOnLine, answersOnLine2));
62  
      print(q);
63  
      printStruct(answers);
64  
    }
65  
  }
66  
}

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: 346 / 527
Version history: 12 change(s)
Referenced in: [show references]