-
Notifications
You must be signed in to change notification settings - Fork 0
/
wiki.h
83 lines (73 loc) · 1.94 KB
/
wiki.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
#ifndef WIKI_H
#define WIKI_H
#pragma once
#include <algorithm>
#include <atomic>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
#include <deque>
using namespace std;
extern float maxfloat;
struct page {
string noun;
int id;
map<string, int> words;
int pglength;
page(string noun_, vector<string> intomap) : noun(noun_) {
pglength = intomap.size();
for (auto i : intomap) {
string temp;
for (auto j : i) {
if (int(j) >= 65 && int(j) <= 90) {
temp.push_back(tolower(j));
} else if (int(j) >= 97 && int(j) <= 122) {
temp.push_back(j);
}
}
if (temp.empty()) {
// cout<< i <<endl;
} else if (temp != "or" && temp != "the" && temp != "and" &&
temp != "a" && temp != "with" && temp != "that" &&
temp != "an" && temp != " References" && temp != "Category" &&
temp != "or" && temp != "we" && temp != "is" &&
temp != "can" && temp != "in" && temp != "to") {
words[temp]++;
// cout<<i<<endl;
}
}
}
};
struct arg_struct {
int id;
string pgname;
arg_struct(int id_, string pgname_) : id(id_), pgname(pgname_){};
};
class wiki {
public:
wiki(){};
void getgrid();
vector<string> retruneight();
~wiki();
protected:
void printpath(vector<int> currpath);
float sumvec(vector<float> v, vector<int> path);
vector<float> addvecf(vector<float> fir, vector<float> sec);
void sortnoun(string pathh, string changeto);
map<string, string> genmap(string path);
string remove_punct(const string& str);
string extract_word(string name);
vector<string> getpage(const string& pagename);
vector<vector<float>> grid; // 2d grid of intersections(same words) of pages
int num_pgs;
vector<page*> allpages;
int mynum = 7;
};
#endif