Uses 911K of libraries. Click here for Pure Java version (13141L/74K).
!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 ]]; sS rules = [[ *person is 19 and a student in college => person is 19 + person is {a student in college} a student in college => a student a student in college => in college *person goes to college in *{New York} => person goes to {college x} + {college x} is in {New York} *person is 14 and living with *y => *person is 14 + *person is living with *y *person is 19 => person is {19 years old} how old is *person? + person is {5 years old} => person is 5 years old ]]; start-thread { test = ai_parseReadingComprehensionTest_v1(text); pnl(test.sentences); // find out speaker's name S name = assertNempty(print("Name", firstMatchesX_rest("My name is ...", test.sentences))); LS sentences = map_curry switcheroo_iToName(curly(name), test.sentences); print("languages: " + ai_languages()); print("test: " + switcheroo_iToName(name, "i am dumb")); pnl(sentences); L<WordTokReplacer> parsedRules = ai_parseStarVarsRules_v2(rules); pnlStruct_nlBefore(parsedRules); //pnl_nlBefore(applyWordTokRules(parsedRules, sentences, seen := sentences)); sentences = map ai_groupGeneralPhrases(sentences); print(); for (S s : sentences) for (S x : applyWordTokRules(parsedRules, s)) print(s + " => " + x); for (ReadingComprehensionTest.Question q : test.questions) { S question = q.question; Pair<Collection<Attractor>, Set<S>> p = applyAttractors_getRuleAndStringEmits(parsedRules, ai_groupGeneralPhrases(question)); for unnull (Attractor a : p.a) { print("New attractor: " + question + " => " + a); for (S out : applyAttractors(ll(a), sentences)) print(" => " + out); } for unnull (S s : p.b) print(question + " => " + s); } } }
Began life as a copy of #1023742
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: | #1023755 |
Snippet name: | "My name is John" [second reading comprehension test, dev.] |
Eternal ID of this version: | #1023755/30 |
Text MD5: | 5fde1f0ced7197c7f934ab2787d2712f |
Transpilation MD5: | e1dcec64e64ecd9f781457e28f246912 |
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 00:05:11 |
Source code size: | 3701 bytes / 101 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 482 / 1299 |
Version history: | 29 change(s) |
Referenced in: | #1023778 - "My name is John" [pronoun resolution, dev.] |