-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexHandler.cpp
More file actions
61 lines (54 loc) · 1.44 KB
/
Copy pathIndexHandler.cpp
File metadata and controls
61 lines (54 loc) · 1.44 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
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by Sammy Timmins on 11/19/20.
//
#include "IndexHandler.h"
/**
* Performs a search in the wordIndex AVL Tree (S.T.)
* @param wordIndex
* @param search
* @param foundTitles
*/
void wordSearch(DSTree<Word>& wordIndex, string& search, map<string, int>& foundTitles)
{
Porter2Stemmer::stem(search);
toLower(search);
Word found, word(search);
if(wordIndex.getNumNodes() > 0)
{
if(wordIndex.find(word))
{
found = wordIndex.get(word);
map<string, int>::iterator it;
int x = 0;
for ( it = found.getTitleList().begin(); it != found.getTitleList().end(); it++)
{
foundTitles.insert (std::pair<string,int>(it->first,it->second));
x++;
}
}
}
else
{
cout << "No index opened, please open an index to search." << endl;
}
}
/**
* Performs a search on the Author HashTable (S.T.)
* @param authorIndex
* @param search
* @param foundTitles
*/
void authorSearch(DSHashTable<string, Title>& authorIndex, string& search, map<string, int>& foundTitles)
{
toLower(search);
Title found;
if(authorIndex.find(search))
{
found = authorIndex.get(search);
for(int i = 0; i < found.getTitles().size(); i++)
{
//foundTitles.insert(found.getTitleAt(i));
foundTitles.insert(std::pair<string,int>(found.getTitles().at(i), i));
}
}
}