Revision 8714
Added by ben leinfelder over 10 years ago
src/edu/ucsb/nceas/metacat/annotation/DatapackageSummarizer.java | ||
---|---|---|
131 | 131 |
Resource entityClass = m.getResource(prov + "Entity"); |
132 | 132 |
Resource personClass = m.getResource(prov + "Person"); |
133 | 133 |
|
134 |
int cnt = 1; |
|
135 |
|
|
136 | 134 |
// these apply to every attribute annotation |
137 |
Individual meta1 = m.createIndividual(ont.getURI() + "#meta" + cnt, entityClass);
|
|
138 |
Individual p1 = m.createIndividual(ont.getURI() + "#person" + cnt, personClass);
|
|
135 |
Individual meta1 = m.createIndividual(ont.getURI() + "#meta", entityClass); |
|
136 |
Individual p1 = m.createIndividual(ont.getURI() + "#person", personClass); |
|
139 | 137 |
p1.addProperty(nameProperty, "Ben Leinfelder"); |
140 | 138 |
meta1.addProperty(identifierProperty, metadataPid.getValue()); |
141 | 139 |
|
142 | 140 |
// loop through the tables and attributes |
141 |
int entityCount = 1; |
|
143 | 142 |
Entity[] entities = dataPackage.getEntityList(); |
144 | 143 |
for (Entity entity: entities) { |
145 | 144 |
String entityName = entity.getName(); |
... | ... | |
148 | 147 |
int attributeCount = 1; |
149 | 148 |
for (Attribute attribute: attributes) { |
150 | 149 |
|
150 |
// for naming the individuals uniquely |
|
151 |
String cnt = entityCount + "_" + attributeCount; |
|
152 |
|
|
151 | 153 |
String attributeName = attribute.getName(); |
152 | 154 |
String attributeLabel = attribute.getLabel(); |
153 | 155 |
String attributeDefinition = attribute.getDefinition(); |
... | ... | |
176 | 178 |
Individual m1 = m.createIndividual(ont.getURI() + "#measurement" + cnt, measurementClass); |
177 | 179 |
Individual a1 = m.createIndividual(ont.getURI() + "#annotation" + cnt, annotationClass); |
178 | 180 |
Individual t1 = m.createIndividual(ont.getURI() + "#target" + cnt, specificResourceClass); |
179 |
String xpointer = "xpointer(/eml/dataSet/" + cnt + "/attributeList/" + attributeCount + ")";
|
|
181 |
String xpointer = "xpointer(/eml/dataSet/" + entityCount + "/attributeList/" + attributeCount + ")";
|
|
180 | 182 |
Individual s1 = m.createIndividual(ont.getURI() + "#" + xpointer, fragmentSelectorClass); |
181 | 183 |
s1.addLiteral(rdfValue, xpointer); |
182 | 184 |
s1.addProperty(conformsToProperty, "http://www.w3.org/TR/xptr/"); |
... | ... | |
197 | 199 |
AllValuesFromRestriction avfr = m.createAllValuesFromRestriction(null, ofCharacteristic, characteristic); |
198 | 200 |
m1.addOntClass(avfr); |
199 | 201 |
} |
200 |
cnt++; |
|
201 | 202 |
} |
203 |
attributeCount++; |
|
202 | 204 |
|
203 |
} |
|
205 |
} |
|
206 |
entityCount++; |
|
204 | 207 |
} |
205 | 208 |
|
206 | 209 |
StringWriter sw = new StringWriter(); |
... | ... | |
292 | 295 |
|
293 | 296 |
String urlParameters = "apikey=" + API_KEY; |
294 | 297 |
urlParameters += "&format=xml"; |
295 |
// urlParameters += "&ontologies=OBOE-SBC";
|
|
296 |
urlParameters += "&ontologies=SWEET"; |
|
298 |
urlParameters += "&ontologies=OBOE-SBC"; |
|
299 |
// urlParameters += "&ontologies=SWEET";
|
|
297 | 300 |
urlParameters += "&text=" + URLEncoder.encode(text, "UTF-8"); |
298 | 301 |
|
299 | 302 |
String url = REST_URL + "/annotator?" + urlParameters ; |
... | ... | |
305 | 308 |
String classURI = classNodeList.item(0).getFirstChild().getNodeValue(); |
306 | 309 |
logMetacat.info("annotator suggested: " + classURI); |
307 | 310 |
Resource subclass = superClass.getModel().getResource(classURI); |
308 |
// TODO: check that it is a subclass of superClass? |
|
309 |
return subclass; |
|
311 |
// check that it is a subclass of superClass |
|
312 |
if (superClass.hasSubClass(subclass)) { |
|
313 |
return subclass; |
|
314 |
} |
|
310 | 315 |
} |
311 | 316 |
} catch (Exception e) { |
312 | 317 |
logMetacat.error("Could not lookup BioPortal annotation for text= " + text, e); |
Also available in: Unified diff
Use OBOE-SBC ontology for looking up concepts (it contains subclasses of our OBOE Characteristic and Standard superclasses). Restrict annotations to only subclasses that fit the OBOE model. Correct the xpointer and individual naming conventions so they are unique, but express the exact entity/attribute being annotated.