-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvertedPageIndex.java
More file actions
executable file
·45 lines (36 loc) · 951 Bytes
/
InvertedPageIndex.java
File metadata and controls
executable file
·45 lines (36 loc) · 951 Bytes
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
//import java.io.IOException;
//import java.util.Scanner;
public class InvertedPageIndex {
MyHashTable invertedIndex;
public InvertedPageIndex() {
// TODO Auto-generated constructor stub
invertedIndex=new MyHashTable(800);
}
public void addPage(PageEntry p) throws LinkedListOutofBoundsException
{
Node<WordEntry> it=p.pgIndex.WordEntries.head;
while(it.getData()!=null)
{
invertedIndex.addPositionsForWord(it.getData());
it=it.next;
}
}
public MySet<PageEntry> getPagesWhichContainWord(String str)
{
WordEntry we=invertedIndex.get(str);
if(we==null)
{
System.out.println("WordNotFound");
return null;
}
MySet<PageEntry> ret=new MySet<PageEntry>();
MyLinkedList<Position> pos=we.getAllPositionsForThisWord();
Node<Position> it=pos.head;
while(it.getData()!=null)
{
ret.Insert(it.getData().getPageEntry());
it=it.next;
}
return ret;
}
}