How about this.

    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

Tired of seeing actual AI not realized, I am taking matters into my own
hands.

I'm going thruogh a series of reading comprehension tests and implementing
them.

Today, for lesson one (see the problem posed above), we use regexps.


  // We help the AI by declaring some "power words" in form of regular
expressions

  transient LS regexps = ll
<http://tinybrain.de:8080/tb/show-snippet.php?id=1003382>("(?<!not
)like", "not like", "dinner", "school", "bed");


Then, some unremarkably short code:

    test = ai_parseReadingComprehensionTest_v1
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023739>(text);
    pnl <http://tinybrain.de:8080/tb/show-snippet.php?id=1008448>(map_curry
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023745>
renderLineWithMatchingRegexpsIC
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023743>(regexps,
test.sentences)); // to see if the regexps work

    for (ReadingComprehensionTest
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023738>.Question q :
test.questions) {
      print_nlBefore
<http://tinybrain.de:8080/tb/show-snippet.php?id=1014665>(q.question);
      LS matchedInQ = matchingRegexpsIC
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023746>(regexps,
q.question);
      if (empty
<http://tinybrain.de:8080/tb/show-snippet.php?id=1002108>(matchedInQ))
matchedInQ = ll
<http://tinybrain.de:8080/tb/show-snippet.php?id=1003382>(""); //
match all
      bool firstType = containsWord
<http://tinybrain.de:8080/tb/show-snippet.php?id=1011436>(q.question,
"first");

      new Best <http://tinybrain.de:8080/tb/show-snippet.php?id=1006090><S>
best;
      for (S answer : q.answers) {
        LS regexps2 = ll
<http://tinybrain.de:8080/tb/show-snippet.php?id=1003382>(quoteRegexp
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023748>(dropPunctuation
<http://tinybrain.de:8080/tb/show-snippet.php?id=1000814>(answer)));
// treat the whole answer as a regexp
        LS regexps2b = matchingRegexpsIC
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023746>(regexps,
answer); // find the regexps that match the answer
        double score = 0;
        if (firstType) { // mode 1: find what appears first in text
          int idx = indexOfEntryContainingAllRegexpsIC
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023751>(regexps2,
test.sentences);
          if (idx < 0)
            idx = indexOfEntryContainingAllRegexpsIC
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023751>(regexps2b,
test.sentences); // try the second set of regexps
          if (idx >= 0) score = -idx; else continue;
        } else { // mode 2: find sentence in text that matches
question + answer best
          score = ai_regexpMixScoreIC
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023749>(regexps2,
matchedInQ, test.sentences, quote
<http://tinybrain.de:8080/tb/show-snippet.php?id=1005595>(answer));
          if (score == 0)
            score = ai_regexpMixScoreIC
<http://tinybrain.de:8080/tb/show-snippet.php?id=1023749>(regexps2b,
matchedInQ, test.sentences, quote
<http://tinybrain.de:8080/tb/show-snippet.php?id=1005595>(answer)); //
try second set of regexps here too
        }
        best.put(answer, score);
      }
      print <http://tinybrain.de:8080/tb/show-snippet.php?id=1000658>(">>
" + or <http://tinybrain.de:8080/tb/show-snippet.php?id=1001741>(best!,
"?")); // print answer
    }

And boom!


















*What happens first?>> Wake upWhat do I like?[1.0] "Books" because: "I like
to read books">> BooksHow do I go to school?[1.0] "I walk." because: "I
walk to school">> I walk.What do I eat for dinner?[1.0] "Soup" because: "My
mother cooks soup for dinner">> SoupWhat do I not like?[1.0] "Going to bed"
because: "I do not like to go bed">> Going to bed*

See you tomorrow.

-- 
Stefan Reich
BotCompany.de // Java-based operating systems

------------------------------------------
Artificial General Intelligence List: AGI
Permalink: 
https://agi.topicbox.com/groups/agi/Tfa2f5184f472f66a-M6bdc8865ff1bfd78a6f8afbd
Delivery options: https://agi.topicbox.com/groups/agi/subscription

Reply via email to