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

  • Thread starter Thread starter carl123
  • Start date Start date
  • Tags Tags
    C++
AI Thread 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?
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
5
Views
3K
Replies
14
Views
34K
Replies
8
Views
2K
Replies
6
Views
2K
Replies
2
Views
2K
Back
Top