Code:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <fstream>
int word_count(string);
int parse(string);
string word(int,string);
int word_identify(string);
int main()
{
string input;
getline(cin,input);
parse(input);
return 0;
}
int parse(string input) {
int word_type=0;
if (input.at(0)!='#') {
int word_type=0;
for (int count=0;count<word_count(input)+1;count++) { word_type+=word_identify(word(count,input)); }
}
cout << endl << word_type<<endl;
return 0;
}
int word_identify (string psz) {
int flag=0;
string temp;
ifstream nounlist("noun1.ygf");
if (!nounlist) cerr << "Problem: noun1list doesnt exist or is being used\n";
nounlist >> temp;
cout << temp << " " << temp.length() << " " << psz << " " << psz.length() << endl;
flag+=(temp==psz)?1:0;
return flag;
}
word(int,string) is a function which returns word number ? from the string
word_count(string) counts the # of words, separated by whitespace