English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
1

I have to write a program for my programming final, and I have a really good idea, I just can't figure out where to start (code wise).

the idea is to be able to type in a word problem (math), and the program would filter the input text and come up with a simple calculation, for example...

Jimmy has 3 apples, Billy took 2 apples away, how many apples does jimmy have?

The program would then filter it to

Jimmy has (3) apples, Billy took(-) (2) apples away, how many apples does jimmy have?(=)

and from the text, it would determine 3-2=

And then it would calculate it and come up with the answer.

I don't want full codes, but what are some ideas to make this work?

And if possible, some ideas for keywords that could be used for this like Bought, Found = +, Lost, dropped = -, Etc

2007-01-11 12:53:48 · 4 answers · asked by Ulver 2 in Computers & Internet Programming & Design

4 answers

Planet Source Code has great examples. http://www.pscode.com

2007-01-11 15:10:40 · answer #1 · answered by Richard H 7 · 0 1

You will need to recognize numbers as either written or as numerals. ( ie two vs 2 John has two apples) Are you going to search for writen numbers like twelve Apples plus twenty four Apples ?

To simplify string searching have you program convert the string to all capitals. Then search for numerals, finding numeric information you can assume the fruits are the next word to the right.

Test for equal nouns 2 Apples + 3 Apples vs 2 Apples + 3 Oranges.... The later the answer would be 5 pieces of fruit or a generic 5 things.

Since this is an excersice you can provide a list of things and names the program will understand for the user to enter. This will limit the vocabulary your program will have to search through.

You can also limit the lenght of text a user can input which will keep the text problem simpler


A suggestion for a simpler program is check writting...
Convert a numeric like $123.67 into written text like on a check.
One Hundred Twenty Three Dollars and Sixty Seven Cents

2007-01-11 22:09:32 · answer #2 · answered by MarkG 7 · 0 0

Nice idea, but if you have to ask how to start, it's probably too hard for you to do. That, OR you would have to limit the 'intelligence' of your program to the point that it's hardly useful (even for illustration purposes) anymore.

One problem you'd have to solve is the ambiguity of words and sentences. What if Jimmy bought 2 (extra) apples, but then Billy BOUGHT 3 apples FROM Jimmy? It's quite hard to make it clear that in the first 'bought'-case, the number of apples that Jimmy owns increases, but in the latter it decreases...

So my suggestion is to make this assignment a bit easier for yourself. :-) One way to do this is, is to limit the grammar that your program understands. You might for example make a program that works with Reverse Polish Notation (see source list below; google RPN for more info), and change the operators (+, -, *, etc.) to English words (plus, minus, multiply, etc.). That would be relatively easy, but hard enough to learn something in the process.

2007-01-11 21:26:34 · answer #3 · answered by Uninformed hence not consenting 7 · 1 0

To achieve this result, you would need to have variables (for Jimmy, and Billy, etc.), so that when your question terminates, the computer will know whose apples you want to know the quantity of.

2007-01-11 21:21:19 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers