У меня проблема.В моем проекте я беру предложение построчно из файла набора данных, в котором по одной фразе в каждой строке.Затем я должен разделить предложения на слова.Но я не мог найти это, как я могу это сделать.
Это коды класса, которые будут читать из набора данных:
class Input{
...
public:
string *word;
string *sentence;
Couple *couple; // int x , int y order of sentence and word
int number;
int line;
...
void readInput(string input);
}
Это коды метода чтения:
void Input::readInput(string input)
{
cout << "Reading the " << input <<endl;
ifstream infile;
infile.open(input.c_str());
if(!infile.is_open()){
cerr << "Unable to open file: " << input << endl << endl;
exit(-1);
}
for(int i=0; i<line ; i++){
getline(infile, sentence[i]);
//infile >> sentence[i];
}
for(int j=0;j<line ;j++){
// I want to separate sentences into words
}
infile.close();
cout << "Finished Reading the " << input <<endl;
}