But, how’d I switch over to some other language from what my bot is programmed in?
I used the logo implementation of Student (see http://www.cs.berkeley.edu/~bh/announce) in my studentagent (http://subbot.org/studentagent).
The way I handle using programs written in other languages is: I have an agent wrapper (http://subbot.org/myagent), which happens to be written in Ruby; from the wrapper I open the ucblogo implementation of Student in a subprocess and communicate with it using files. (Other third-party program i use, such as link grammar, I can communicate with using stdin and stdout.)
Here is a trial run of studentagent. Note: I had to reinstall ucblogo to the “ucblogo” subdirectory in the studentagent directory. Note also that due to some timing issues which I haven’t resolved, the bot’s answers are somewhat stochastic :) For example I had to ask the “customer” question 3 times before I got the answer, and the “price” question twice. This is because I am writing Student’s answers to a file, and due to timing issues the file write sometimes fails, and so I get the last file written, or a zero length file, which results in an error.
I should fix these problems. The reason I stopped working on this agent was that I found that it overfits the examples provided by Bobrow. If I varied the questions just a little bit, the program didn’t understand them. So I’ve put off making the program more general…
C:\studentagent>ruby studentbot.rb
Hello
I have loaded C:/studentagent-api.yaml.
> student: Tom has 3 times as many fish as Mary has guppies. Mary has 2 guppies. How many fish does Tom have?
The number of fish Tom has is 6
> The sum of two numbers is 96, and one of the numbers is 16 larger than the other number. Find the two numbers.
The one of the numbers is 56; The other number is 40
> If the number of customers Tom gets is twice the square of 20 percent of the number of advertisements he runs, and the number of advertisements he runs is 45, what is the number of customers Tom gets?
Couldn’t do the problem: undefined method `each’ for nil:NilClass
> If the number of customers Tom gets is twice the square of 20 percent of the number of advertisements he runs, and the number of advertisements he runs is 45, what is the number of customers Tom gets?
Couldn’t do the problem: undefined method `each’ for nil:NilClass
> If the number of customers Tom gets is twice the square of 20 percent of the number of advertisements he runs, and the number of advertisements he runs is 45, what is the number of customers Tom gets?
The number of customers Tom gets is 162
> A number is multiplied by 6. This product is increased by 44. This result is 68. Find the number.
The number is 4
> The price of a radio is 69.70 dollars. If this price is 15 percent less than the marked price, find the marked price.
The number is 4
> The price of a radio is 69.70 dollars. If this price is 15 percent less than the marked price, find the marked price.
The marked price is 82 dollars
>
—-
‘I wanted to know, how can I make my bot understand “mathematical expressions”?’
I also use Google’s Calculator to do math. For example here’s a problem that came up in Problem Set 3 of the nlp-class:
> .c lg((36 * 1791)/(18 * 3124))
lg((36 * 1791)/(18 * 3124))? 0.197370884
http://subbot.org/calcagent/
I also have a Wolfram Alpha agent: http://subbot.org/waagent/