-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollation.cpp
More file actions
48 lines (41 loc) · 1.45 KB
/
Collation.cpp
File metadata and controls
48 lines (41 loc) · 1.45 KB
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
//
// Collation.cpp
// Search_CPP1_5
//
// Created by Jatin Tayal on 29/07/19.
// Copyright © 2019 Adobe. All rights reserved.
//
#include "Collation.h"
Collation collation;
extern int totalIndexedFiles;
extern map<int, string> globalfileIndex;
void Collation::setCollationType(int type){
collationType = type;
}
int Collation::getCollationType(){
return collationType;
}
int Collation::findWordsOccurenceInFile(int fileIndex, vector<map<int, int> > result, vector<string> tokens){
int total = 0;
for(int i =0; i<tokens.size(); i++){
total += result[i][fileIndex];
cout<<"\t\t\tQuery String : "<< tokens[i] <<"\t\tOccurence : "<< result[i][fileIndex] << endl;
}
return total;
}
void Collation::printHorizontalCollation(map<int,int > res, string queryString){
cout<<"\t\t\tQuery String : "<< queryString <<endl;
int totalOccurences = 0;
for(int i=0 ; i<totalIndexedFiles ; i++){
cout<<"\t\tFile : "<<globalfileIndex[i]<<"\t\tOccurence : "<< res[i] << endl;
totalOccurences += res[i];
}
cout <<"\t\t\t\tTotal Occurences : "<<totalOccurences<<endl;
}
void Collation::printVerticalCollation(vector<map<int, int> > result, vector<string> tokens){
for(int i=0 ; i<totalIndexedFiles ; i++){
cout<<"\t\tFile : "<<globalfileIndex[i]<<endl;
int totalOccurences = findWordsOccurenceInFile(i,result, tokens);
cout<<"\t\tTotal occurence : "<<totalOccurences<<endl;
}
}