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

30
LINES

< > BotCompany Repo | #1023739 // ai_parseReadingComprehensionTest_v1

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4740L/30K).

static ReadingComprehensionTest ai_parseReadingComprehensionTest_v1(S rawText, O... _) {
  optPar bool printText = true;
  new ReadingComprehensionTest test;
  
  LS paragraphs = pnlStructIf(printText, paragraphsTokC(rawText));
  L<Bool> isQ = map(rcurry_swic("Question"), paragraphs);
  int idx = falsesFollowedByTrues_changeIndex_assertNotNull(isQ);
  LS textPart = takeFirst_clone(paragraphs, idx);
  LS questionsPart = sublist(paragraphs, idx);
  if (isPreciseMultiDashesHeading(first(textPart))) popFirst(textPart);
  test.text = joinWithEmptyLines(textPart);
  test.sentences = pnlIf(printText, sentences(test.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));
    add(test.questions, nu(ReadingComprehensionTest.Question.class, question := q, +answers));
    print(q);
    printStruct(answers);
  }
  
  ret test;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1379 anonymous Remarkable 2019-07-09 02:34:43  delete 

add comment

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: 441 / 587
Version history: 14 change(s)
Referenced in: [show references]