forked from marcocor/query-annotator-stub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WATFeaturesMain.java
43 lines (34 loc) · 2.67 KB
/
WATFeaturesMain.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
package annotatorstub.main;
import java.lang.invoke.MethodHandles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import annotatorstub.utils.WATRelatednessComputer;
import it.unipi.di.acube.batframework.utils.WikipediaApiInterface;
public class WATFeaturesMain {
private final static Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static void main(String[] args) throws Exception {
WikipediaApiInterface api = WikipediaApiInterface.api();
WATRelatednessComputer.setCache("relatedness.cache");;
int obamaId = api.getIdByTitle("Barack Obama");
int merkelId = api.getIdByTitle("Angela Merkel");
int germanyId = api.getIdByTitle("Germany");
LOG.info("Wikipedia IDs: Obama:{} Merkel:{} Germany:{}", obamaId, merkelId, germanyId);
LOG.info("Probability that `Obama' is a link in Wikipedia: {}", WATRelatednessComputer.getLp("Obama"));
LOG.info("Probability that `Barack Obama' is a link in Wikipedia: {}", WATRelatednessComputer.getLp("Barack Obama"));
LOG.info("Probability that `Barack' is a link in Wikipedia: {}", WATRelatednessComputer.getLp("Barack"));
LOG.info("Jaccard relatedness between Germany and Angela Merkel: {}", WATRelatednessComputer.getJaccardRelatedness(germanyId, merkelId));
LOG.info("Jaccard relatedness between Germany and Barack Obama: {}", WATRelatednessComputer.getJaccardRelatedness(germanyId, obamaId));
LOG.info("Jaccard relatedness between Angela Merkel and Barack Obama: {}", WATRelatednessComputer.getJaccardRelatedness(merkelId, obamaId));
LOG.info("MW relatedness between Germany and Angela Merkel: {}", WATRelatednessComputer.getMwRelatedness(germanyId, merkelId));
LOG.info("MW relatedness between Germany and Barack Obama: {}", WATRelatednessComputer.getMwRelatedness(germanyId, obamaId));
LOG.info("MW relatedness between Angela Merkel and Barack Obama: {}", WATRelatednessComputer.getMwRelatedness(merkelId, obamaId));
LOG.info("Probability that `obama' links to Barack Obama in Wikipedia: {}", WATRelatednessComputer.getCommonness("obama", obamaId));
LOG.info("Probability that `barack obama' links to Barack Obama in Wikipedia: {}", WATRelatednessComputer.getCommonness("barack obama", obamaId));
LOG.info("Probability that `barack' links to Barack Obama in Wikipedia: {}", WATRelatednessComputer.getCommonness("barack", obamaId));
LOG.info("Probability that `barack' links to Germany in Wikipedia: {}", WATRelatednessComputer.getCommonness("barack", germanyId));
for (int id : WATRelatednessComputer.getLinks("obama"))
LOG.info("'obama' links to {} with probability {}", api.getTitlebyId(id), WATRelatednessComputer.getCommonness("obama", id));
api.flush();
WATRelatednessComputer.flush();
}
}