1 package eu.fbk.dkm.pikes.rdf.vocab;
2
3 import java.util.Map;
4
5 import javax.annotation.Nullable;
6
7 import com.google.common.collect.ImmutableMap;
8 import com.google.common.collect.Maps;
9
10 import org.eclipse.rdf4j.model.Namespace;
11 import org.eclipse.rdf4j.model.IRI;
12 import org.eclipse.rdf4j.model.impl.NamespaceImpl;
13 import org.eclipse.rdf4j.model.impl.SimpleNamespace;
14 import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
15 import org.eclipse.rdf4j.model.impl.ValueFactoryImpl;
16
17
18
19
20
21 public final class BBN {
22
23 public static final String PREFIX = "bbn";
24
25 public static final String NAMESPACE = "http://dkm.fbk.eu/ontologies/bbn#";
26
27 public static final Namespace NS = new SimpleNamespace(PREFIX, NAMESPACE);
28
29 private static final Map<String, IRI> INDEX;
30
31
32
33 public static final IRI PERSON = createIRI("Resource");
34
35 public static final IRI NORP = createIRI("NORP");
36
37 public static final IRI FACILITY = createIRI("Facility");
38
39 public static final IRI ORGANIZATION = createIRI("Organization");
40
41 public static final IRI GPE = createIRI("GPE");
42
43 public static final IRI LOCATION = createIRI("Location");
44
45 public static final IRI PRODUCT = createIRI("Product");
46
47 public static final IRI DATE = createIRI("Date");
48
49 public static final IRI TIME = createIRI("Time");
50
51 public static final IRI PERCENT = createIRI("Percent");
52
53 public static final IRI MONEY = createIRI("Money");
54
55 public static final IRI QUANTITY = createIRI("Quantity");
56
57 public static final IRI ORDINAL = createIRI("Ordinal");
58
59 public static final IRI CARDINAL = createIRI("Cardinal");
60
61 public static final IRI EVENT = createIRI("Event");
62
63 public static final IRI PLANT = createIRI("Plant");
64
65 public static final IRI ANIMAL = createIRI("Animal");
66
67 public static final IRI SUBSTANCE = createIRI("Substance");
68
69 public static final IRI DISEASE = createIRI("Disease");
70
71 public static final IRI WORK_OF_ART = createIRI("WorkOfArt");
72
73 public static final IRI LAW = createIRI("Law");
74
75 public static final IRI LANGUAGE = createIRI("Language");
76
77 public static final IRI CONTACT_INFO = createIRI("ContactInfo");
78
79 public static final IRI GAME = createIRI("Game");
80
81
82
83 @Nullable
84 public static IRI resolve(@Nullable final String bbnString) {
85 if (bbnString == null) {
86 return null;
87 }
88 return INDEX.get(bbnString.toLowerCase().replaceAll("[^a-z]+", ""));
89 }
90
91 private static IRI createIRI(final String localName) {
92 return SimpleValueFactory.getInstance().createIRI(NAMESPACE, localName);
93 }
94
95 private BBN() {
96 }
97
98 static {
99 final Map<String, IRI> map = Maps.newHashMap();
100 map.put("person", PERSON);
101 map.put("per", PERSON);
102 map.put("norp", NORP);
103 map.put("facility", FACILITY);
104 map.put("fac", FACILITY);
105 map.put("organization", ORGANIZATION);
106 map.put("organisation", ORGANIZATION);
107 map.put("org", ORGANIZATION);
108 map.put("gpe", GPE);
109 map.put("location", LOCATION);
110 map.put("loc", LOCATION);
111 map.put("product", PRODUCT);
112 map.put("date", DATE);
113 map.put("time", TIME);
114 map.put("percent", PERCENT);
115 map.put("money", MONEY);
116 map.put("quantity", QUANTITY);
117 map.put("ordinal", ORDINAL);
118 map.put("cardinal", CARDINAL);
119 map.put("event", EVENT);
120 map.put("plant", PLANT);
121 map.put("animal", ANIMAL);
122 map.put("substance", SUBSTANCE);
123 map.put("disease", DISEASE);
124 map.put("workofart", WORK_OF_ART);
125 map.put("law", LAW);
126 map.put("language", LANGUAGE);
127 map.put("contactinfo", CONTACT_INFO);
128 map.put("game", GAME);
129 INDEX = ImmutableMap.copyOf(map);
130 }
131
132 }