Guest Posted January 13, 2011 Report Share Posted January 13, 2011 Working on a c++ artificial intelligence program; I'd like to know if anyone here knows how to pick up an entire sentence input to a console, plus any ideas for improvement on its "brain" would be appreciated. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 13, 2011 Report Share Posted January 13, 2011 I find this to be a good resource for C++ functions: cplusplus.com I'm not sure of the exact parameters that you're looking for, but here are a couple suggestions.* If every sentence is going to be on it's own line, you can try using the getline function. It would be something like: string str; getline(cin, str); //str now has all the data from the console up to the first newline character. Otherwise, as far as I know, you need to write your own method for parsing to the end of a line by searching for sentence-ending punctuation. If you know that every sentence is going to end with a '.', you can still use the getline function, but with the delimiter overloaded: string str; getline(cin, str, '.'); //str now has everything up to the first '.' and the '.' has been discarded from the stream. * Sounds like an ambitious project. AI is no simple task, no matter how trivial a task you are trying to develop. Good luck! Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 13, 2011 Report Share Posted January 13, 2011 Thank you, very much. I have a... rather intricate system set up. However, I just couldn't get an entire sentence. I'll try this and let you know if it worked. Thanks again. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 13, 2011 Report Share Posted January 13, 2011 It works. I can't believe I hadn't tried this yet. Thank you very much. Quote Link to comment Share on other sites More sharing options...
0 unreality Posted January 14, 2011 Report Share Posted January 14, 2011 Can you keep us posted as to your progress? I'm interested Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 Sure, I need help again though. Right now it's still at the stage of copy catting. However, I need to figure out how to pull a sentence with ( ) around it out of a file and store it into a string. Any ideas? I am programming it to copy cat before formulating its own sentences. Quote Link to comment Share on other sites More sharing options...
0 unreality Posted January 14, 2011 Report Share Posted January 14, 2011 your best bet is to use the three include files listed here: http://www.cplusplus.com/doc/tutorial/files/ If you have c++ on your computer you more than likely have these libraries already. Then just use the i/o stream "double greater than / less than" operators >>, << to input and print, respectively. Use substring or if you want, something fancier like find/replace, to get rid of the parentheses Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 the file is formatted (whatever the question is) whatever the answer is. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 (edited) Is there a way I can use find replace to clear all the spaces? The system works with single word questions. Edited January 14, 2011 by Darth Legion Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 (edited) Wait, I don't need that anymore. I just need to figure out an algorithm for every aspect of the English language..... Edited January 14, 2011 by Darth Legion Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 For todays update, I am teaching the program to recognize several keywords and phrases as either good or bad. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 Wait, I don't need that anymore. I just need to figure out an algorithm for every aspect of the English language..... Yeah, there are entire branches of Linguistics focused on that. We haven't mapped our language for ourselves yet, so it's hard to create a mapping for an AI... Natural Language Processing is its own field of study in AI. I'm not sure the scope of your project, but as it's a still evolving field, I imagine that you will find some parts hard to solve. Good luck with it though, and like unreality said, keep us up to date, especially if you run into trouble. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 Okay, I've learned enough from teaching it to copy cat that I am abandoning that area and moving straight into formulation of a sentence. I am still working on a system to map out how long to make a sentence and how many of each words where. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 14, 2011 Report Share Posted January 14, 2011 Let's see if our intelligence combined is enough to come up with a randomized system. I'm open to ideas on how to decide sentence length. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 15, 2011 Report Share Posted January 15, 2011 (edited) Update: Using sentence structure and vowel usage to decide sentence length. BTW, I'm, more than likely, a novice to programing comparatively to most readers. Edited January 15, 2011 by Darth Legion Quote Link to comment Share on other sites More sharing options...
0 Guest Posted January 18, 2011 Report Share Posted January 18, 2011 Getting frustrated with this project. Taking a break from it. Will resume updates when I pick it up again. In the meantime, I am making a console version of Risk. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted February 11, 2011 Report Share Posted February 11, 2011 Still trying to find an equation of some sort to make it speak intelligently. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted February 11, 2011 Report Share Posted February 11, 2011 Still trying to find an equation of some sort to make it speak intelligently. I'd be interested to hear if you have any luck in this regard, but as I mentioned earlier, you might try looking at the field of Linguistics to see how complicated the task is that you've set for yourself. No one has managed to perfectly map the English (or any other language, so far as I'm aware) grammar to be able to always produce a sound and complete sentence with an unrestricted vocabulary. That being said, a little research into linguistics and sentence structure might help you find an equation that will approximate what you're seeking. Sentence diagramming would be a good place to start. Good luck! Quote Link to comment Share on other sites More sharing options...
0 Guest Posted February 11, 2011 Report Share Posted February 11, 2011 Will also help with my English score on the ACT.... Quote Link to comment Share on other sites More sharing options...
0 Guest Posted February 16, 2011 Report Share Posted February 16, 2011 English is a very hodgepodge language...it might be easier if you were to try teaching it to speak/understand a more formulaic and regular language first Quote Link to comment Share on other sites More sharing options...
0 Guest Posted February 16, 2011 Report Share Posted February 16, 2011 English is a very hodgepodge language...it might be easier if you were to try teaching it to speak/understand a more formulaic and regular language first There is no such thing as a regular language. Unless you count fabricated languages like Esperanto, which nobody speaks anyway. Quote Link to comment Share on other sites More sharing options...
0 unreality Posted February 16, 2011 Report Share Posted February 16, 2011 I think he means a very simple/logical language of the programmer's own invention... that would definitely be a good starting point Quote Link to comment Share on other sites More sharing options...
0 Guest Posted February 16, 2011 Report Share Posted February 16, 2011 Good idea. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted March 1, 2011 Report Share Posted March 1, 2011 I was actually thinking of Latin; although the order of words in Latin isn't strictly regulated, the endings attached to words allow little to no uncertainty as to the function of a given word in a given sentence, as well as identifying both the part of speech and which adjectives are associated with which noun. And within the realm of languages, English's tendency to borrow words and grammatical structures from any and every language it encounters makes it particularly irregular. Quote Link to comment Share on other sites More sharing options...
0 unreality Posted March 2, 2011 Report Share Posted March 2, 2011 nevertheless I'd recommend starting with a _very_ simple language of your own invention (very very very simple) and then once you get that working, extrapolate to more complex linguistic rules/patterns Quote Link to comment Share on other sites More sharing options...
Question
Guest
Working on a c++ artificial intelligence program; I'd like to know if anyone here knows how to pick up an entire sentence input to a console, plus any ideas for improvement on its "brain" would be appreciated.
Link to comment
Share on other sites
24 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.