-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWordEntry.java
More file actions
47 lines (47 loc) · 1.02 KB
/
WordEntry.java
File metadata and controls
47 lines (47 loc) · 1.02 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
public class WordEntry
{
public String str;
public MyLinkedList<Position> well=new MyLinkedList<Position>();
public AvlTree avt=new AvlTree();
public WordEntry(String word)
{
str=word;
}
void addPosition(Position position)
{
Node<Position> v=new Node<Position>(position,null,null);
well.addLast(v);
avt.insert(position,str);
}
void addPositions(MyLinkedList<Position> positions)
{
Node<Position> n1=positions.header.getNext();
while (n1!=positions.trailer)
{
Node<Position> n2=new Node<>(n1.getElement(),null,null);
well.addLast(n2);
n1=n1.getNext();
}
}
MyLinkedList<Position> getAllPositionsForThisWord()
{
return well;
}
float getTermFrequency(String word)
{
Node<Position> fi=well.header.getNext();
float c=0,j=500;
float a;
for (int i=0;i<well.size();i++)
{
if ((fi.getElement().getPageEntry().na).equals(word))
{
j=fi.getElement().getPageEntry().totalWords();
c++;
}
fi=fi.getNext();
}
a=c/j;
return a;
}
}