-
Notifications
You must be signed in to change notification settings - Fork 0
/
WordEntry.java
56 lines (56 loc) · 1.15 KB
/
WordEntry.java
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
public class WordEntry
{
String str;
MyLinkedList<Position> wpos;
AVLTree<Position> wtree;
WordEntry(String word)
{
str=word;
wpos=new MyLinkedList<Position>();
wtree=new AVLTree<Position>();
}
void addPosition(Position position)
{
Node<Position> a=new Node<Position>(position);
wpos.insertNode(a);
//wtree.root=wtree.insertNodeInTree(wtree.root,position);
}
void addPositions(MyLinkedList<Position> positions)
{
wpos=wpos.unionlist(positions);
}
MyLinkedList<Position> getAllPositionsForThisWord()
{
return wpos;
}
AVLTree<Position> prepareAVLTree()
{
wpos.ptr=wpos.head;
while(wpos.ptr.next!=null)
{
wpos.ptr=wpos.ptr.next;
wtree.root=wtree.insertNodeInTree(wtree.root,wpos.ptr.data);
}
return wtree;
}
float getTermFrequency(String word)
{
wpos.ptr=wpos.head;
int count=0;
PageEntry tmp1=new PageEntry("stack_datastructure_wiki");
while(wpos.ptr.next!=null)
{
wpos.ptr=wpos.ptr.next;
Position tmp=(Position)wpos.ptr.data;
if(tmp.p.nameOfPage.equals(word))
{
tmp1=tmp.p;
count=count+1;
}
}
int t=tmp1.total;
//System.out.println(t);
float d=(float)(count/(t*1.0));
return d;
}
}