Skip to content

Commit

Permalink
[Upd] Add resource property
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Kulich committed Feb 15, 2023
1 parent 886c508 commit 9afd7d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ public class ExtractTermOccurrencesModule extends AnnotatedAbstractModule {
//:source-resource-uri
private StreamResource sourceResource;

Extraction extraction = new Extraction();

@Override
protected ExecutionContext executeSelf() {
Model inputRDF = this.getExecutionContext().getDefaultModel();

ResIterator rows = inputRDF.listResourcesWithProperty(RDF.type, CSVW.RowUri);
Map<String, List<Element>> annotatedElements = new HashMap<>();

Extraction extraction = new Extraction();
extraction.addPrefix("ddo","http://onto.fel.cvut.cz/ontologies/application/termit/pojem/");

rows.forEach(row -> {
Expand All @@ -73,6 +74,7 @@ protected ExecutionContext executeSelf() {
assert e.parentNode() != null;
String parentTag = ((Element) e.parentNode()).text();

addLiteral(res, createProperty(Constants.RDFa.RESOURCE), fullIri(e.attr(Constants.RDFa.RESOURCE)));
addLiteral(res, createProperty(Constants.WHOLE_TEXT), StringEscapeUtils.unescapeJava(((Element) e.parentNode()).html()));
addLiteral(res, createProperty(Constants.REFERENCES_ANNOTATION), StringEscapeUtils.unescapeJava(e.toString()));
addLiteral(res, createProperty(Constants.REFERENCES_TEXT), parentTag);
Expand Down Expand Up @@ -141,4 +143,18 @@ public String getDataPrefix() {
public void setDataPrefix(String dataPrefix) {
this.dataPrefix = dataPrefix;
}

private String fullIri(String possiblyPrefixed) {
possiblyPrefixed = possiblyPrefixed.trim();
final int colonIndex = possiblyPrefixed.indexOf(':');
if (colonIndex == -1) {
return possiblyPrefixed;
}
final String prefix = possiblyPrefixed.substring(0, colonIndex);
if (!extraction.getPrefixes().containsKey(prefix)) {
return possiblyPrefixed;
}
final String localName = possiblyPrefixed.substring(colonIndex + 1);
return extraction.getPrefixes().get(prefix) + localName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ private String fullIri(String possiblyPrefixed) {
public void addPrefix(String prefix, String value) {
prefixes.put(prefix, value);
}

public Map<String, String> getPrefixes() {
return prefixes;
}
}

0 comments on commit 9afd7d5

Please sign in to comment.