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 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

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