Instructions

For this project you will be designing and implementing a system, in C++ (98, 11, or 14), that initially reads in a list of words and their synonyms. It can then take in a paragraph and process each word, such that if the word is in the list of synonyms, the word will be repeatedly replaced with a random synonym some user defined number of times. Additionally, the program can take in two paragraphs and perform a similarity analysis to determine if the second could be created from the first using the random synonym replacement described previously.

Requirements

This assignment has two parts: a design portion and an implementation portion.

Design Document

For the design portion, you must generate documentation, in PDF format, describing your system. The purpose of this is for you to explain not just what your system is doing, and how it is doing it, but why. You will need to justify your design decisions in a concise, informative manner. Justifications such as "I did this because it was easy" are not sufficient, as you should actually explain why a particular data structure or algorithm was more efficient, effective, or optimal. Additionally, commented code, while sometimes helpful in small examples, is not a sufficient explanation in and of itself. Your explanations and justifications are expected to be presented in prose and in paragraph format, i.e. not bulleted lists. Further, part of the evaluation of your design document is the apparent amount of thought and effort that went into its creation.

This document should be divided into three main parts, and should follow the provided template.

In the first part, in one or two paragraphs you should describe the project in your own words and give a brief overview of the problem. Do not copy and paste this from the instruction document.

For the second part, you should describe the data structures you used in your system. What, if any, objects or structs did you create to store data? How did you organize and manage them? What types of formal data structures did you make use of (trees, graphs, arrays, hashes, etc)? In a few paragraphs, describe in detail how you stored the various data elements in your system, and be sure to provide sufficient justification of your methodology.

For the third part, you should describe functionality of your system. How is data moved and transformed? How is it read in? How is it output? What are the various major functions you constructed and how do they work? In a few paragraphs, describe in detail how your system works, and be sure to provide sufficient justification of your methodology. You might also consider including diagrams to more easily visualize how all of the pieces fit together.

Implementation

Your program must provide the following functionality and adhere to the following constraints:

Allow the user to choose the file describing synonym list

  • Do NOT hardcode the filename into your program
  • Each line will have a word followed by a colon and then a comma delimited list of all of its synonyms
  • All words will be lowercase, but may contain other symbols such as hyphens or apostrophes
  • Assume all words containing hyphens or apostrophes count as a single word
  • The synonyms list should be stored as a undirected graph, where each word is represented by a single node and two nodes are considered adjacent if they are synonyms
  • The graph should be constructed as either an adjacency list or an adjacency matrix that you construct yourself
  • Additionally, all words on a line should be considered synonyms of one another

Allow the user to choose between performing a random synonym replacement or performing a paragraph similarity analysis

If the user chooses to perform the random synonym replacement

  • Allow the user to choose the file containing their paragraph
  • Do NOT hardcode the filename into your program
  • Allow the user to input how many times a word should be randomly swapped for a synonym
    • In some cases there may not be enough synonyms to perform the user requested number of replacements, but your system should attempt to perform as many of the requested number of replacements as possible
    • You system may not replace a word with a synonym that it replaced, e.g. if the word "great" was replaced the synonym good, you may not immediately replace good with great again to achieve the user requested number of replacements. Cycles are allowed, but must be made up of at least three nodes
  • Your system should then examine each word in the paragraph and attempt to make the required number of repeated synonym replacements for each word.
    • This requires the use of your synonym graph
  • The altered paragraph should be output to the user, in its original paragraph form, i.e. each sentence should not be on a new line, but should follow the previous sentence.

If the user chooses to perform the paragraph similarity analysis

  • Allow the user to choose the two files containing their paragraphs
  • Do NOT hardcode the filenames into your program
  • Your system should then examine each word in both paragraphs, in order, and determine if the two words are the same or at least synonyms.
    • If the two words are not the same, a searching algorithm should be used to determine if there is a chain of synonym replacements that could transform one word into the other
    • You may not use any of the searching algorithms provided by any C/C++ libraries, the STL, or the Boost libraries. You must write your own search algorithm, using the ones discussed in class.
  • If any words are determined to not be the same, or at least synonyms, between the two paragraphs, the user should be informed that the paragraphs are not similar
  • If all words are determined to be the same, or at least synonyms, between the two paragraphs, the user should be informed that the paragraphs are similar

Your code must be well commented.

You must provide a short README file which includes your name and explains how to compile and run your program.

Additionally, you may write a makefile if you want your code to compile with additional flags.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.