C++ Assignment NEED HELP URGENTLY

Reply

Join Date: Nov 2006
Posts: 1
Reputation: georgioue is an unknown quantity at this point 
Solved Threads: 0
georgioue georgioue is offline Offline
Newbie Poster

C++ Assignment NEED HELP URGENTLY

 
0
  #1
Nov 28th, 2006
Guys hello, i`m a new member here http://images.devshed.com/fda/smilies/smile.gif Hello to everybody...I need urgently help... I have an assignment for C++.
"We have a collection of emails. This collection has emails from Linguist.org, these mails are legal. these are in a file called ling_filenames.txt. We also have a collection of spam emails in spam_filenames.txt. We have also a file called keywords.txt which has the key words to deside if an email is spam or ling. One word each line. Write a C++ program which checks the email collections and prints:
<messagecollection messages ="n">

<message file=" " category="spam" features="m">
<feature id="i1" freq="fi1"> k1 </feature>
<feature id="i2" freq="fi2"> k2 </feature>
...
<feature id="im" freq="fim"> km </feature>
</message>
...
<message file=" " category="legit| features="r">
<feature id="j1" freq="fj1"> q1 </feature>
<feature id="j2" freq="fj2"> q2 </feature>
...
<feature id="jr" freq="fjr"> qr </feature>
</message>
...
</messagecollection>

This is my code until now....PLEASE HELP ME!!!!!
  1. #include <iostream>
  2. #include <set>
  3. #include <fstream>
  4. #include <vector>
  5. #include <string>
  6. using namespace std;
  7.  
  8. string Keys_path="keywords.txt";
  9. string ling="ling_filenames.txt";
  10. string spam="spam_filenames.txt";
  11.  
  12. vector <string> words()
  13. {
  14. vector <string> Keys;
  15. string word;
  16. ifstream keysfile (Keys_path.c_str());
  17. while (keysfile>>word)
  18. Keys.push_back(word);
  19. return Keys;
  20. }
  21.  
  22. void Check (vector <string> keywords, string file, int c)
  23. {
  24. void CheckFile(vector <string> Kwords, string TFile);
  25. string word;
  26. int i;
  27. vector <string> AllFiles;
  28. ifstream files(file.c_str());
  29. while (files>>word)
  30. AllFiles.push_back(word);
  31. for (i=0; i<AllFiles.size(); i++) {
  32. CheckFile(keywords, AllFiles[i]);
  33. // cout<<
  34. }
  35. }
  36.  
  37. void CheckFile(vector <string> Kwords, string TFile)
  38. {
  39. set <string> txt;
  40. int i;
  41. string word, a;
  42. ifstream x (TFile.c_str());
  43. while (x>>word)
  44. txt.insert(word);
  45. for(i=0; i<Kwords.size(); i++)
  46. {
  47. a=Kwords[i];
  48. if(txt.find(a)!=txt.end()) {
  49. cout<<
  50. }
  51. }
  52. }
  53.  
  54. void CountLines (vector <string> Kwords, string TFile)
  55. {
  56. set <string> text;
  57. int i;
  58. int n=0;
  59. ifstream files(ling.c_str());
  60. while (files>>line) {
  61. AllFiles.push_back(line);
  62. }
  63. for(i=0; i<AllFiles.size(); i++)
  64. n++;
  65. ifstream files2(spam.c_str());
  66. while (files2>>line) {
  67. AllFiles2.push_back(line);
  68. }
  69. for(i=0; i<AllFiles2.size(); i++)
  70. n++;
  71. return n;
  72. }
  73.  
  74.  
  75. int main()
  76. {
  77. vector <string> Keywords=words();
  78. int c=0;
  79. int FeatureNumbers=0;
  80. Check(Keywords,ling,c);
  81. c++;
  82. Check(Keywords,spam,c);
  83. return 0;
  84. }
Last edited by WaltP; Nov 28th, 2006 at 7:51 am. Reason: Please use code tags -- see the post at the top of the forum about codes
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,151
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1435
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: C++ Assignment NEED HELP URGENTLY

 
0
  #2
Nov 28th, 2006
>>PLEASE HELP ME!!!!!

help you do what? does your program compile ? (hint: no it does not).
what errors does your compiler produce?

  1. if(txt.find(a)!=txt.end()) {
  2. cout<<
  3. }
Above is incomplete statement.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 8
Reputation: Nimz is an unknown quantity at this point 
Solved Threads: 0
Nimz's Avatar
Nimz Nimz is offline Offline
Newbie Poster

Re: C++ Assignment NEED HELP URGENTLY

 
0
  #3
Apr 20th, 2008
i did try compiling it and it gave me error messages
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,151
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1435
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: C++ Assignment NEED HELP URGENTLY

 
0
  #4
Apr 20th, 2008
What are some of the errors -- you'll have to post them because I can't see your computer's monitor from my chair.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC