1 package eu.fbk.dkm.premon.util;
2
3 import eu.fbk.dkm.premon.premonitor.propbank.Frameset;
4
5 import java.util.regex.Matcher;
6 import java.util.regex.Pattern;
7
8
9
10
11
12 public class PropBankResource extends PremonResource {
13
14 static final Pattern ONTONOTES_FILENAME_PATTERN = Pattern.compile("(.*)-([a-z]+)\\.xml");
15
16 public PropBankResource(String fileName, boolean isOntoNotes, String defaultType)
17 throws Exception {
18 this.fileName = fileName;
19 this.type = defaultType;
20 this.lemma = fileName.replaceAll("\\.xml", "");
21
22 if (isOntoNotes) {
23 Matcher matcher = ONTONOTES_FILENAME_PATTERN.matcher(fileName);
24 if (matcher.matches()) {
25 this.type = matcher.group(2);
26 this.lemma = matcher.group(1);
27 } else {
28 throw new Exception(
29 "File " + fileName + " does not appear to be a good OntoNotes frame file");
30 }
31 }
32 }
33
34 public Frameset getMain() {
35 return (Frameset) this.main;
36 }
37
38 public void setMain(Frameset main) {
39 this.main = main;
40 }
41 }