Jump to content
BrainDen.com - Brain Teasers
  • 0


Guest
 Share

Question

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

  • 0

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. :blink: Good luck! :thumbsup:

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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... :wacko:

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. :thumbsup:

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

  • 0

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 by Darth Legion
Link to comment
Share on other sites

  • 0

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! :thumbsup:

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...