-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
118 lines (111 loc) · 3.09 KB
/
Main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import java.awt.EventQueue;
import java.util.*;
import javax.swing.JFrame;
/*! Main class */
public class Main {
private EntityResolution er;
/*!
* Constructor of Main Class
* A new instance of the EntityResolution Class is created.
* WWWParsing and AuthorParsing is called.
*/
public Main()
{
er = new EntityResolution();
er.parseWWW();
er.parseAllAuthors();
}
/*!
* MoreThanK function creates a set of authors.
* Iterates the Map<String,Author> and if the value
* of the Number of publications is greater than K ,
* appends it to the set and returns it.
*/
public Set<Author> getMoreThanK(int k)
{
Set<Author> KAuthors = new TreeSet<Author>();
for(Map.Entry<String, Author> entry : er.ourMainMap.entrySet())
{
if(entry.getValue().getNumOfPublications() > k)
{
KAuthors.add(entry.getValue());
}
}
return KAuthors;
}
/*!
* Takes the AuthorName as the argument and returns the Publications
* by that author after Parsing.
*/
public List<Publication> getPublicationByAuthor(String authorName)
{
return er.parsePublicationByAuthor(authorName);
}
/*!
* This Sorts the List of Publications By Year
*/
public void sortPublicationByDate(List<Publication> publ)
{
Collections.sort(publ, new Comparator<Publication>()
{
public int compare(Publication a, Publication b)
{
return Integer.valueOf(b.getYear()).compareTo(a.getYear());
}
});
}
/*!
* A function for Binary Search.
*/
public int binarySearch(List<Publication> publ, int searchYear)
{
int l = 0;
int h = publ.size();
while(l < h )
{
int mid = (l + h)/2;
if(publ.get(mid).getYear() < searchYear)
h = mid;
else
l = mid + 1;
}
return l;
}
/*!
* This first creates a list of string of titleQueries entered by the user.
* A list iterator iterates the List and removes the articles.
* Next, the parsePublicationByTitle method is called which is stored in a map.
*/
public Map<Integer, List<Publication> > getPublicatonByTitle(String title)
{
String[] splitTitle = title.split(" ");
List<String> listTitle = Arrays.asList(splitTitle);
Iterator<String> listIterator = listTitle.iterator();
while(listIterator.hasNext())
{
String word = listIterator.next();
if(word.equalsIgnoreCase("is") | word.equalsIgnoreCase("a") | word.equalsIgnoreCase("an") | word.equalsIgnoreCase("the") | word.equalsIgnoreCase("on") | word.equalsIgnoreCase("for") | word.equalsIgnoreCase("of"))
{
listIterator.remove();
}
}
Map<Integer, List<Publication> > publ = er.parsePublicationByTitle(listTitle);
return publ;
}
/*!
* This is the MAIN method where the GUI is invoked.
*/
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
EntityResolution er = new EntityResolution();
DBLP_GUI frame = new DBLP_GUI();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
}