944,198 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1679
  • C++ RSS
Nov 28th, 2006
0

C++ Assignment NEED HELP URGENTLY

Expand Post »
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!!!!!
cpp Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
georgioue is offline Offline
1 posts
since Nov 2006
Nov 28th, 2006
0

Re: C++ Assignment NEED HELP URGENTLY

>>PLEASE HELP ME!!!!!

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

C++ Syntax (Toggle Plain Text)
  1. if(txt.find(a)!=txt.end()) {
  2. cout<<
  3. }
Above is incomplete statement.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Apr 20th, 2008
0

Re: C++ Assignment NEED HELP URGENTLY

i did try compiling it and it gave me error messages
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nimz is offline Offline
8 posts
since Mar 2008
Apr 20th, 2008
0

Re: C++ Assignment NEED HELP URGENTLY

What are some of the errors -- you'll have to post them because I can't see your computer's monitor from my chair.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: convert char to hexadecimal
Next Thread in C++ Forum Timeline: default variable as a pointer in class





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC