I have to get input from the console for a paragraph, and break the paragraph into sentences and then words.
I'm trying to do this with the C++ string class.
I have the following code for getting the paragraph
string getParagraph() {
do {
getline(cin, sentence);
paragraph += sentence + "\n";
} while (sentence.length() >0);
}
I don't know how to break the paragraph into separate sentences, and then into separate words? I think there is a member function for the string class that leeks you peek ahead to see the next character, and the unget functions would help for this(to unget whitespace or punctuation), but I don't remember the name of the first member function.
Run through the paragraph finding full stops - add each substring to a vector of sentences. Then run through the each sentence look for spaces and add each substring to a vector of words.