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

62
LINES

< > BotCompany Repo | #1023778 // "My name is John" [pronoun resolution, dev.]

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

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

!7

// Text + questions from https://lingua.com/english/reading/john/

cmodule John > DynPrintLog {
  transient ReadingComprehensionTest test;
  switchable S text = [[
    
    Hi! Nice to meet you! My name is John Smith. I am 19 and a student in college. I go to college in New York. My favorite courses are Geometry, French, and History. English is my hardest course. My professors are very friendly and smart. It’s my second year in college now. I love it!
    
    I live in a big house on Ivy Street. It’s near the college campus. I share the house with three other students. Their names are Bill, Tony, and Paul. We help each other with homework. On the weekend, we play football together.
    
    I have a younger brother. He just started high school. He is 14 and lives with my parents. They live on Mulberry Street in Boston. Sometimes they visit me in New York. I am happy when they visit. My Mom always brings me sweets and candy when they come. I really miss them, too!    
    
    Question 1:
    Where does John Smith go to college?
    1 Berlin    2 Boston
    3 New York  4 Paris
    
    Question 2:
    What is John Smith’s hardest course?
    1 Art   2 English
    3 Math  4 French
    
    Question 3:
    Who shares a house with John Smith?
    1 Anna, Margaret, and Tanya 2 Bill, John, and Tom
    3 Frank, Tony, and Mike     4 Bill, Tony, and Paul
    
    Question 4:
    How old is John Smith’s younger brother?
    1 fourteen  2 eleven
    3 seven     4 thirteen
    
    Question 5:
    What does John Smith’s Mom bring him when they visit?
    1 Candy and ice cream 2 Fruits and vegetables
    3 Sweets and candy    4 Flowers and coffee

  ]];
  
  start-thread {
    test = ai_parseReadingComprehensionTest_v1(text, printText := false);
    LS sentences = switcheroo_iToSpeakersName(test.sentences);
    
    pnl(sentences);
    Set<S> brw = ai_backReferencingWords();
    FullPhraseCache nounStash = fullPhraseCache(ai_nounsAndNounPhrases());
    for (S s : sentences) {
      LS tok = wordTok(s);
      L<Int> indices = indicesOfCodeTokensContainedInSet(tok, brw);
      L<IntRange> nounIndices = fullPhraseCache_intRanges(nounStash, tok);
      LS nouns = map_curry joinSubList_intRange(tok, nounIndices);
      print(sfu(nouns) + " | " + sfu(getIndices(tok, indices)) + " | " + s);
      
    }
    
    for (S s : sentences) {
      //fullPhraseCache_intRanges(mechFullPhraseCache(sentences));
    }
  }
}

Author comment

Began life as a copy of #1023755

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: #1023778
Snippet name: "My name is John" [pronoun resolution, dev.]
Eternal ID of this version: #1023778/15
Text MD5: a385de723ddb3af76663b0d844928296
Transpilation MD5: 5e8761991712aa25a20f218dd4e038b1
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-09 13:10:14
Source code size: 2512 bytes / 62 lines
Pitched / IR pitched: No / No
Views / Downloads: 346 / 709
Version history: 14 change(s)
Referenced in: [show references]