Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Build on following simple implementation by adding the following functionalities. // Ppt End Semester Project.cpp : Defines the entry point for the console application. //

Build on following simple implementation by adding the following functionalities.

// Ppt End Semester Project.cpp : Defines the entry point for the console application. //

#include "stdafx.h" // moj compiler #include #include //za falove #include // za unos i ispis stringova #include #include #include

using namespace std;

void tidy_me_up(string line) //uzima string sa svim rijecimai simbolima { fstream myfile; //incijalizacija fstream za uvoz izvoz podatkaa iz fajla myfile.open("tittyfile.txt", ios::out | ios::app); // otvaranje fajla titty file kao out sa spasavanjem prijasnjih ispisa.

if (myfile.is_open()) //testira dali je otvoreno { int tolower(int c); std::for_each(line.begin(), line.end(), [](char &c) { c = ::tolower(c);

});

bool trigger_marker = false; //triger za pomoc na liniji 35-37 for (int i = 0; i (zadnji element) i++

{ if (trigger_marker == true) //ako je triger true znaci da je pogodio karakter za brisanje i eliminsao ga { if (i != 0) // fazon iza ovoga je ako imas dva znaka jedan za drugim npr "/. on ce obristi navodnik i onda uraditi i++ ali kako rade stringovi on ce obrisati " i onda staviti / na njegovo mjesto i time ne obrisati njega jer je i++ presao na naredni elemnt. { i--; // vrati counter da se taj element provjeri koji nije. }

}

trigger_marker = false; // vraca trger na false da dalje moze radit kroz nove iteacije petlje. if ((line[i] == '"') || (line[i] == ',') || (line[i] == '.') || (line[i] == '-') || (line[i] == '_') || (line[i] == '?') || (line[i] == '*')) // projevera simbola { line.erase(i, 1); //brisanje jednog elemtna to jest simbola ako je jedan od navedenoh gore trigger_marker = true; // triger na true }

//if (line[i] == ' ') //ako je space pebaci sav text na novu liniju //{

// line[i] = ' '; // prebacivanje texta na novu liniju //}

} } else { cout

myfile

} #include

int funkcija_za_ispitivanje_jednakosti_stringova(string line, string wordlist_line) { int marker; int counter = 0; int line_lenght, wordlist_line_lenght; line_lenght = line.length(); wordlist_line_lenght = wordlist_line.length();

for (int i = 0; i

}

int main() { ifstream myfile("input.txt"); //otvara odredjieni text file sa spam emailom string line; // incijalizacija stringa gdje ce se nalazitit citasv email sa greskama i simbolima int wordlist_word_score[10] = { 10,20,20,15,30,10,10,20,15,25 }; string wordlist[10] = { "$","earn per week","double your","income in one week","trial that lasts forever","opportunity","income","cash","month free trial","your love life" };

if (myfile.is_open()) // if ce provjeriti dali je otvoren fajl if(open ) {ovjde } else {ovjde } {

while (getline(myfile, line)) // while ce raditi dok ima sta iz imput.txt pokupiti. while je zastita da ako ima ikakva vrsta extra linija on ne zbuni se i ne zaboravi ih. u normalnom radu while ce samo jednom proci. { tidy_me_up(line); //poziva tidy_me_up funkciju za sredjianje simbola u imput.txt (void) }

myfile.close(); // zatvara file imput.txt } else //ako nije otvoren fajl na pocetku ispis "unable to read memory" { cout

ifstream mytityfile("tittyfile.txt"); string tittyline; //mozda treba cistiti int spam_chance = 0; if (mytityfile.is_open()) {

int counter = 1; string temp; while (getline(mytityfile, tittyline)) { for (int i = 0; i = 10) && (spam_chance = 50) cout

std::ofstream clear_tity_file; clear_tity_file.open("tittyfile.txt", std::ofstream::out | std::ofstream::trunc); clear_tity_file.close(); return 0; // nemoj zaboraviti ocistit tittyfile kad program zavrsi da se program moze vise od jednom aktivirati. }

image text in transcribed

Build a spam filter that for each word in the email allows a Levenshtein distance of l. So for example, "Duble your amezing oportunity for a sgreat incom and lats of cash csh casch" will have the same score as the original phrase, as every single word has Levenshtein distance that is not larger than 1. To make the concept more clear, here are some more examples below: "Month free triels " should receive a score of 0 because "triels" is more than distance 1 away from the word emph'trial" (it has both the substitution and an extra letter), so we can not count that word, and consequently the entire phrase. "Yours Love lifes opportuniti" should receive the score of 25 + 10 = 35. "$$ per week" should receive the score of 10 because "$$" is a string "$" that has an extra letter. Build a spam filter that for each word in the email allows a Levenshtein distance of l. So for example, "Duble your amezing oportunity for a sgreat incom and lats of cash csh casch" will have the same score as the original phrase, as every single word has Levenshtein distance that is not larger than 1. To make the concept more clear, here are some more examples below: "Month free triels " should receive a score of 0 because "triels" is more than distance 1 away from the word emph'trial" (it has both the substitution and an extra letter), so we can not count that word, and consequently the entire phrase. "Yours Love lifes opportuniti" should receive the score of 25 + 10 = 35. "$$ per week" should receive the score of 10 because "$$" is a string "$" that has an extra letter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What service would you like to see improved? How?

Answered: 1 week ago

Question

Enhance the basic quality of your voice.

Answered: 1 week ago

Question

Describe the features of and process used by a writing team.

Answered: 1 week ago