C/C++ C++ Spell Checker: Abbreviation Decoding & Tweet Suggestions

  • Thread starter Thread starter carl123
  • Start date Start date
  • Tags Tags
    C++
Click For Summary
The discussion focuses on developing a program that decodes tweet abbreviations and suggests corrections for common misspellings. Key features include creating a list of supported abbreviations, checking for misspellings, and allowing users to input a complete tweet for abbreviation decoding. The current implementation includes a series of conditional statements to match specific abbreviations like "LOL" and "OMG." A suggestion is made to improve the code by using an array for abbreviations and looping through it instead of relying on multiple if statements, which would streamline the process and enhance efficiency.
carl123
Messages
55
Reaction score
0
1) Create a few tweet abbreviations that can be decoded. Add support for abbreviations.

2) For abbreviations that do not match the supported abbreviations, check for common misspellings. Provide a suggestion for correct abbreviation along with the decoded meaning. For example, if the user enters "LLO", your program can output "Did you mean LOL? LOL = laughing out loud".

3) Allows the user to enter a complete tweet (140 characters or less) as a single line of text. Search the resulting string for those common abbreviations and print a list of each abbreviation along with its decoded meaning.

4) Convert the user's tweet to a decoded tweet, replacing the abbreviations directly within the tweet.

I already did number 1.

This is what I have so far:

Code:
#include <iostream>
#include <string>
using namespace std;

int main() {
   string origTweet;
   
   cout << "Enter abbreviation from tweet: " << endl;
   cin >> origTweet;
   
   if (origTweet == "LOL") {
      cout << "LOL = laughing out loud" << endl;
   }
   else if (origTweet == "BFN") {
      cout << "BFN = bye for now" << endl;
   }
   else if (origTweet == "FTW") {
      cout << "FTW = for the win" << endl;
   }
   else if (origTweet == "IRL") {
      cout << "IRL = in real life" << endl;
   }   
   else if (origTweet == "ILY") {
      cout << "ILY = i love you" << endl;
   }   
   else if (origTweet == "OMG") {
      cout << "OMG == oh my gosh" << endl;
   }
   else {
      cout << "Sorry, don't know that one." << endl;
   }
   return 0;
}
 
Technology news on Phys.org
Hello carl123,

I have deleted your duplicate threads so that we don't have multiple postings of the same question. We discourage multiple threads of the same topic because not only is it redundant, but it can potentially lead to duplication of effort on the part of our helpers, whose time is valuable.

Regarding your questions, have you considered entering your abbreviations into an array and then looping through them rather than using a large if construct?
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 14 ·
Replies
14
Views
34K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K