Introduction: In this assignment you will be analyzingsearch queries from various engines. (A daunting task, like what does that even mean) In short you will prompt the user for the name of a file,...

1 answer below »


Introduction:


In this assignment you will be analyzingsearch queries from various engines. (A daunting task, like what does that even mean)



In short you will prompt the user for the name of a file, attempt to open said file, and if succeeded then you will begin to parse and output as follows.
Each line will contain one search query (type a search into google and look at the URL, that thing)
You are to parse each one for information and output it to a file while also tracking some information about everything you have parsed. (Ok those were some words lets break that down)



In short you will prompt the user for the name of a file, attempt to open said file, and if succeeded then you will begin to parse and output as follows.
Each line will contain one search query (type a search into google and look at the URL, that thing)
You are to parse each line for certain information, more on that later, and output this information to a file. While doing this you will track some information about the file. (Ok that was alot of words lets break that down)




Explanation
:



For each input line: (all examples bellow are reffering to the following query(https://www.google.com/search?q=some+query&oq=some+query&aqs=chrome..69i57j0l5.2991j0j9&sourceid=chrome&ie=UTF-8))



  • You will grab the site that they are querying


    • would be google.com in this case



  • You will grab the query string

    • In this case it would be "some query"

    • Note it is not "some+query" but some query



  • You will grab any options (if there are any)

    • There are many of these in the above query

      • oq="some query"

      • aqs = "chrome...69i57j0l5.2991j0j9"

      • sourceid="chrome"

      • ie = "UTF-8"







For the file:



  • Track the number of queries that were in the file

  • The average number of options (these count all things that are not the query string q)

  • Average length of the query string (just the q parameter)

  • Average length of the url




Output:


The output is split into two parts. The information for each of the individual url will output to a file and the output about the file statistics will be output tostandard output (terminal).



Screen Output Example:


Statistics for

-------------------------
Number of Queries:

Average length of URL:

Average length of query string:

Average number of options:


File Output example:


.
.
.
:

-------------------
URL:

:

:

\n (this should be a blank line just put a newline)
.
.
.


Input:


Ask the user to enter the file name. Here is anexample file

Preview the document







.
.
.




Requirements:



  • You must buld a namespace called "helpers" you will define any fuctions that help calculate (like averages) or manipulate (maybe some strings)

    • You are required to have at least two functions in this namespace

      • Calculating averages and maybe putting the spaces in the query string in place of '+' are good canidates



    • You may use more functions than this (and i recommend you do) but you must do the following

      • If the function is a "helper" (see the above explinations about what a helper is) is must be in the helper namespace

      • This will be mentioned bellow but you must document your function

        • Include what the function does and what the parameters are







  • You must build a namespace called "interface" you will define any functions that help you prompt the user / print to file

    • You are required to have at least two functions in this namespace

      • Printing information to the screen (standard input), maybe your final output to the screen would be a good canidate

      • Another would be a function that prints a line and the corsponding "----" line that will match up with it



    • You may use more functions than this (and i recommend you do) but you must do the following

      • If the function is a "helper" (see the above explinations about what a helper is) is must be in the helper namespace

      • This will be mentioned bellow but you must document your function

        • Include what the function does and what the parameters are







  • All functions must be documented above a prototype

  • Each time a line has "----" (dashes under it)

    • The dash line must be the same length as the line above it



Answered Same DayApr 10, 2021

Answer To: Introduction: In this assignment you will be analyzingsearch queries from various engines. (A...

Arun Shankar answered on Apr 11 2021
148 Votes
a.out
input.txt
https://www.google.com/search?q=test&oq=test&aqs=chrome..69i57j69i61l2j69i60j0j69i59.561j0j7&sourceid=chrome&ie=UTF-8
https://www.google.com/search?q=ther
e+should+be+some+space&oq=there+should+be+some+space&aqs=chrome..69i57j0l5.5239j0j7&sourceid=chrome&ie=UTF-8
https://www.google.com/search?q=list+of+queries&oq=list+of+queries&aqs=chrome..69i57j0l5.4278j0j7&sourceid=chrome&ie=UTF-8
https://www.google.com/search?q=testing&oq=testing&aqs=chrome..69i57j69i60l3j35i39j0.1989j0j9&sourceid=chrome&ie=UTF-8
https://duckduckgo.com/?q=now+here+is+a+different+one&t=hb&ia=web
https://duckduckgo.com/?q=lets+see+how+many+here+and+until+when+will+cause&t=hb&ia=web
https://www.google.com/search?q=where+food+near+me&oq=where+food+near+me&aqs=chrome..69i57j0l5.8995j0j9&sourceid=chrome&ie=UTF-8&dlnr=1&sei=Z_LcWtjsBsazzwKf0KCwDw
https://duckduckgo.com/?q=where+food+near+me&t=hb&ia=web
main
main.cpp
#include
#include
#include
using namespace std;
namespace helper
{
/* A helper function to replace the + symbol
in a string with a space */
string replace(string s)
{
for(int i=0;i if(s[i]=='+')
s[i]=' ';
return s;
}
string getarguments(string input, string *aptr, string *bptr)
{
char a[100],b[100];
int i=1,j=0;
for(;input[i]!='=';++i)
{
a[i-1] = input[i];
}
a[i-1] = '\0';
for(++i;((i {
b[j] = input[i];
}
b[j] = '\0';
*aptr = string(a);
*bptr = string(b);
return input.substr(i,input.length()-i);
}
}
namespace interface
{
string outputFileName;
ofstream outfile;
void...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here