-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
73 lines (67 loc) · 2.8 KB
/
main.cpp
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
//
// Created by gmook on 3/14/2021.
//
#include <iostream>
#include "JSONTokenizer.hpp"
#include "JSONParser.hpp"
#include "Matrix.hpp"
int main(int argc, char *argv[]) {
std::ifstream inputStream;
inputStream.open(argv[1], std::ios::in); // open for reading
if (!inputStream.is_open()) {
std::cout << "Unable to open " << argv[1] << ". Terminating...";
exit(2);
}
inputStream.close();
//***NOTE FOR PROF***
// Please grade phase 2 AND 3, confirmed via README.
// IN ORDER TO GRADE PHASE 2, SIMPLY CHANGE
// testPhase2 to TRUE.
// THANK YOU.
//*******************
int testPhase2 = false;
if( testPhase2 ) {
JSONTokenizer jsonTokenizer(argv[1]);
JSONParser parser(jsonTokenizer);
EntitySet createSet = parser.parseJSONEntity();
createSet.print();
} else {
//****FOR FILE 1****
//Create a instance of Tokenizer that opens file 1
JSONTokenizer jsonTokenizerPreSelect(argv[1]);
JSONToken token;
JSONParser parserPreSelect(jsonTokenizerPreSelect);
EntitySet setPreSelect;
EntityInstance instancePreSelect;
setPreSelect = parserPreSelect.parseJSONEntity();
// Populate matrixPreSelect. This is NOT a matrix but a vector
// This creates a vector of pairs from the first document
// that each element is in the form (ID, GPA)
std::vector<std::pair<std::string, double>> matrixPreSelect = setPreSelect.getterForMatrix();
//*****************
//****FOR FILE 2****
// Create a instance of Tokenizer that opens file 2
JSONTokenizer jsonTokenizerSelect(argv[2]);
JSONToken tokenSelect;
JSONParser parserSelect(jsonTokenizerSelect);
EntitySet setSelect;
EntityInstance instanceSelect;
setSelect = parserSelect.parseJSONEntity();
// Populate matrixSelect. This is NOT a matrix but a vector
// This creates a vector of pairs from the second document
// that each element is in the form (ID, GPA)
std::vector<std::pair<std::string, double>> matrixSelect = setSelect.getterForMatrix();
//*****************
// Next we create a object of Matrix class that stores the resultant vectors
// this allows us to pass them into functions from the Matrix class
// a period is used to access these functions as usual
Matrix currentMatrix(matrixPreSelect,matrixSelect);
// The getGpa() functions is very important. It is used to
// create a vector of GPA pairs from document 1 and document 2.
currentMatrix.getGpa();
// The checkAndPrint() function itself also calls on the generateColumn() function
// in order to create the populated matrix.
currentMatrix.checkAndPrint();
}
return 0;
}