-
Notifications
You must be signed in to change notification settings - Fork 0
/
Document.java
56 lines (45 loc) · 1.71 KB
/
Document.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
/*
* File = Document.java
* Date = Friday, February 14, 2020
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
public class Document {
private ArrayList<String> rank = new ArrayList<>(); // the unique tokens ranked in descending order by frequency
private HashMap<String, ArrayList<Integer>> appearances = new HashMap<>(); // the document ids each token appears in
private HashMap<String, Integer> frequencies = new HashMap<>(); // the freqencies of each token
private HashMap<String, Double> tfidf = new HashMap<>(); // the TF-IDF value of each token
private int id; // the document id
private String title; // the document / article title
Document(int id, ArrayList<String> rank, HashMap<String, ArrayList<Integer>> appearances, HashMap<String, Double> tfidf,
HashMap<String, Integer> frequencies) {
this.frequencies = frequencies;
this.id = id;
this.rank = rank;
this.tfidf = tfidf;
title = "";
} // Document
public HashMap<String, ArrayList<Integer>> allAppearances() {
return appearances;
} // allAppearances()
public ArrayList<String> rankedList() {
return rank;
} // rankedList()
public HashMap<String, Integer> frequencies() {
return frequencies;
} // frequencies()
public HashMap<String, Double> tfidf() {
return tfidf;
} // tfidf()
public String getTitle() {
return title;
} // getTitle()
public void setTitle(String title) {
this.title = title;
} // setTitle()
@Override
public String toString() {
return title;
} // toString()
} // Document