You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by jg...@apache.org on 2017/09/13 10:55:28 UTC
[5/6] any23 git commit: Fix testing issue
Fix testing issue
- add documentation to RDFUtils class
Signed-off-by:Jacek Grzebyta <gr...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/5a4d3429
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/5a4d3429
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/5a4d3429
Branch: refs/heads/master
Commit: 5a4d3429a098307debb2432641e5c7dc827301c9
Parents: 94caa68
Author: Jacek Grzebyta <gr...@gmail.com>
Authored: Sat Sep 9 21:13:37 2017 +0100
Committer: Jacek Grzebyta <gr...@gmail.com>
Committed: Sat Sep 9 21:13:37 2017 +0100
----------------------------------------------------------------------
.../any23/extractor/yaml/YAMLExtractor.java | 6 +++-
.../java/org/apache/any23/rdf/RDFUtils.java | 31 ++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/any23/blob/5a4d3429/core/src/main/java/org/apache/any23/extractor/yaml/YAMLExtractor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/extractor/yaml/YAMLExtractor.java b/core/src/main/java/org/apache/any23/extractor/yaml/YAMLExtractor.java
index 4eae6b9..ab411da 100644
--- a/core/src/main/java/org/apache/any23/extractor/yaml/YAMLExtractor.java
+++ b/core/src/main/java/org/apache/any23/extractor/yaml/YAMLExtractor.java
@@ -123,7 +123,11 @@ public class YAMLExtractor implements Extractor.ContentExtractor {
for (String k : node.keySet()) {
- Resource predicate = RDFUtils.makeIRI(k, file, true);
+ /* False prevents adding _<int> to the predicate.
+ Thus the predicate pattern is:
+ "some string" ---> ns:someString
+ */
+ Resource predicate = RDFUtils.makeIRI(k, file, false);
Value value = buildNode(file, node.get(k), out);
out.writeTriple(nodeURI, RDF.TYPE, vocab.mapping);
out.writeTriple(nodeURI, (IRI) predicate, value);
http://git-wip-us.apache.org/repos/asf/any23/blob/5a4d3429/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/rdf/RDFUtils.java b/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
index f6e3a8c..498b01d 100644
--- a/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
+++ b/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
@@ -573,14 +573,45 @@ public class RDFUtils {
}
}
+ /**
+ * Ref {@link #makeIRI(java.lang.String, org.eclipse.rdf4j.model.IRI, boolean) }.
+ * @param docUri
+ * @return
+ */
public static Resource makeIRI(IRI docUri) {
return makeIRI("node", docUri);
}
+ /**
+ * Ref {@link #makeIRI(java.lang.String, org.eclipse.rdf4j.model.IRI, boolean) }.
+ * @param type
+ * @param docIRI
+ * @return
+ */
public static Resource makeIRI(String type, IRI docIRI) {
return makeIRI(type, docIRI, false);
}
+ /**
+ * Creates implementation of {@link Resource} from given arguments: <it>type</it> and
+ * <it>docIRI</it>.
+ * <ul>
+ * <li>The <it>type</type> argument is converted following Java naming conventions with
+ * {@link StringUtils#implementJavaNaming(java.lang.String) }.
+ *
+ * <li>The <it>docIRI</it> is treated as a namespace. If it ends with '/' character than
+ * stays unchanged otherwise the hash character '#' is added.
+ *
+ * <li>If <it>addId</it> is TRUE than combination of underscore and the node identifier is added to
+ * the end ('{@code_<int>'}).
+ * </ul>
+ *
+ * @param type
+ * @param docIRI
+ * @param addId
+ * @return {@link Resource} implementation
+ * @see http://www.geeksforgeeks.org/java-naming-conventions/
+ */
public static Resource makeIRI(String type, IRI docIRI, boolean addId) {
// preprocess string: converts - -> _