I am making a simple program in C++ that takes sentences/comments from Youtube from a file, these sentences all end with "!!!!". I need to get these sentences into an array list. The rest of the project isn't important, its comparing the individual words in each array and counting the number of negative and positive words from two other arrays which I got working into arrays because they are all separated by white spaces.
I am not sure how to set up the delimiter of "!!!!". I know there are a total of 94 sentences. I am aware that I hard coded the number of positive and negatives in my two working arrays, that is not an issue I am currently concerned about, I can improve this later once it all works.
In summary: I need to make a string array that is 94 strings long that takes input from a file, where every string/sentence ends with
"!!!!"
After that I should be able to figure out how to separate every word in each string and match them to the words in the other 2 arrays and count how many match for each.
Any help would be greatly appreciated, thanks in advance.
Here is the code I got so far.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string posArr[2006];
ifstream positive("positive-words.txt");
if (positive.is_open()) {
for (int i = 0; i < 2006; i++) {
positive >> posArr[i];
}
}
positive.close();
string negArr[4783];
ifstream negative("negative-words.txt");
if (negative.is_open()) {
for (int i = 0; i < 4783; i++) {
negative >> negArr[i];
}
}
negative.close();
string commentsArr[94];
ifstream comments("youtubecomments-dataset.txt");
//I tried a bunch of different code that didn't work so I erased it.
// cout << posArr[0] << endl; //tested the array is working
// cout << negArr[0] << endl;
cin.ignore();
cin.get();
return 0;
}
Here are the first few lines from the Negative txt file: 2-faced 2-faces abnormal abolish abominable
Here are the first few lines from the Positive txt file: a+ abound abounds abundance abundant
Here are the first few sentences from the comments text file:
Sync system sucks big time, a total turn off when considering this car.!!!!40mpg ain't that good these days, niether is a 5 speed gearbox!!!!On the Explorer Base the radio is a lot easier and I paired my phone up no problem. Everything worked but the voice command doesn't work.!!!!I have one of these as a rental right now. The electronics aren't really that hard to figure out... But the automatic transmission is HORRIBLE. It's juttery, gringy, and jumpy. And the gears shift all over the place. I'd never buy one of these with an auto tranny. I bet it's great in manual.!!!!you're exactly as tall as i am :)!!!!
It is not structured, sentences start on the same line, and the spacing is bad in some places, but they all end with !!!!
There are 94 in total.