-
Notifications
You must be signed in to change notification settings - Fork 1
/
WebPage.h
executable file
·98 lines (70 loc) · 2.83 KB
/
WebPage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// required headers go here
#ifndef WEBPAGE_H
#define WEBPAGE_H
#include "lib/set.h"
#include <vector>
#include <map>
#include <string>
#include <iostream>
class WebPage{
public:
WebPage (); // constructor that creates an empty page
WebPage (std::string filename);
/* constructor that initializes the page from the given file.
Should throw an exception if the file does not exist
or has other problems. */
~WebPage (); // destructor
Set<std::string> allWords () const;
/* Returns a set containing all individual words on the web page. */
bool operator==(const WebPage& other) const;
bool operator<(const WebPage& other) const;
void filter (std::string &key);
friend std::ostream & operator<< (std::ostream & os, const WebPage & page);
/* Declares an operator we can use to print the web page. */
Set<WebPage*> allOutgoingLinks () const;
/* Returns "pointers" to all webpages that this page has links to.
As discussed above, this could be as a set or via an iterator,
and it could be as actual pointers, or as strings,
or possibly other. */
Set<WebPage*> allIncomingLinks () const;
/* Returns "pointers" to all webpages that link to this page.
Same consideration as previous function. */
std::string filename () const;
/* Returns the filename from which this page was read. */
Set<std::string>* allLinks();
Set<std::string> allEmphs();
Set<WebPage*>::iterator beginIncoming();
Set<WebPage*>::iterator endIncoming();
Set<WebPage*>::iterator beginOutgoing();
Set<WebPage*>::iterator endOutgoing();
void set_PR (double num);
double get_PR () const;
void set_TR (double num); //must impl
double get_TR () const;
std::vector<std::string> getOriginal() const;
Set<std::string> allAtext() const;
/* Based on which overall architecture you choose, you may
also need/want some or all of the following functions. */
void parse ();
/* actually parses the content of the filename that was passed
to the constructor into the object. */
void addIncomingLink (WebPage* start);
/* Adds a link from start to the current page
in the current page's storage. */
void addOutgoingLink (WebPage* target);
/* Adds a link from the current page to the target
in the current page's storage. */
private:
bool CheckHeader (std::string &key);
Set<std::string> words;
std::vector<std::string> original;
std::string name;
Set<WebPage*> outgoingLinks;
Set<WebPage*> incomingLinks;
Set<std::string> link;
Set<std::string> atext;
Set<std::string> emphSet;
double PR;
double total_relevance;
};
#endif