Author: rwesten
Date: Thu Jun 28 05:53:01 2012
New Revision: 1354819
URL: http://svn.apache.org/viewvc?rev=1354819&view=rev
Log:
implements STANBOL-633 as stated by the issue. Also adds validation for
fise:confidence-level to the EnhancementStructureHelper (STANBOL-612)
Modified:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/Properties.java
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/TechnicalClasses.java
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/resources/fise.owl
incubator/stanbol/trunk/enhancer/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java
Modified:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/Properties.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/Properties.java?rev=1354819&r1=1354818&r2=1354819&view=diff
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/Properties.java
(original)
+++
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/Properties.java
Thu Jun 28 05:53:01 2012
@@ -159,6 +159,12 @@ public class Properties {
*/
public static final UriRef ENHANCER_ENTITY_LABEL = new UriRef(
NamespaceEnum.fise + "entity-label");
+ /**
+ * The confidence level (introducdes by
+ * <a
herf="https://issues.apache.org/jira/browse/STANBOL-631">STANBOL-631</a>)
+ */
+ public static final UriRef ENHANCER_CONFIDENCE_LEVEL = new UriRef(
+ NamespaceEnum.fise + "confidence-level");
/**
* Internet Media Type of a content item.
Modified:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/TechnicalClasses.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/TechnicalClasses.java?rev=1354819&r1=1354818&r2=1354819&view=diff
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/TechnicalClasses.java
(original)
+++
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/rdf/TechnicalClasses.java
Thu Jun 28 05:53:01 2012
@@ -16,6 +16,10 @@
*/
package org.apache.stanbol.enhancer.servicesapi.rdf;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.clerezza.rdf.core.UriRef;
/**
@@ -105,5 +109,77 @@ public final class TechnicalClasses {
*/
public static final UriRef DCTERMS_LINGUISTIC_SYSTEM = new UriRef(
NamespaceEnum.dc + "LinguisticSystem");
+
+ /**
+ * The confidence level of {@link #ENHANCER_ENHANCEMENT}s
+ */
+ public static final UriRef FNHANCER_CONFIDENCE_LEVEL = new UriRef(
+ NamespaceEnum.fise + "ConfidenceLevel");
+
+ /**
+ * Enumeration over the four instance of the {@link
#FNHANCER_CONFIDENCE_LEVEL}
+ * class as introduced by
+ * <a
herf="https://issues.apache.org/jira/browse/STANBOL-631">STANBOL-631</a>)
+ * <p>
+ * {@link #name()} returns the local name; {@link #toString()} the URI as
+ * {@link String}.
+ * @author Rupert Westenthaler
+ *
+ */
+ public static enum CONFIDENCE_LEVEL_ENUM{
+ certain,ambiguous,suggestion,uncertain;
+
+ private final UriRef uri;
+ private final String localName;
+
+ private CONFIDENCE_LEVEL_ENUM() {
+ localName = "cl-"+name();
+ uri = new UriRef(NamespaceEnum.fise+localName);
+ }
+
+ public String getLocalName(){
+ return localName;
+ }
+
+ public String toString() {
+ return uri.toString();
+ };
+
+ public UriRef getUri(){
+ return uri;
+ }
+
+ private static final Map<UriRef,CONFIDENCE_LEVEL_ENUM> uriRef2enum;
+ private static final Map<String,CONFIDENCE_LEVEL_ENUM> uri2enum;
+ static {
+ Map<UriRef,CONFIDENCE_LEVEL_ENUM> ur = new
HashMap<UriRef,TechnicalClasses.CONFIDENCE_LEVEL_ENUM>();
+ Map<String,CONFIDENCE_LEVEL_ENUM> us = new
HashMap<String,TechnicalClasses.CONFIDENCE_LEVEL_ENUM>();
+ for(CONFIDENCE_LEVEL_ENUM cl : CONFIDENCE_LEVEL_ENUM.values()){
+ ur.put(cl.getUri(), cl);
+ us.put(cl.toString(), cl);
+ }
+ uriRef2enum = Collections.unmodifiableMap(ur);
+ uri2enum = Collections.unmodifiableMap(us);
+ }
+ /**
+ * Getter for the fise:ConfidenceLevel instance for the {@link UriRef}
+ * @param uri the URI
+ * @return the fise:ConfidenceLevel instance or <code>null</code> if
the
+ * parsed URI is not one of the four defined instances
+ */
+ public static CONFIDENCE_LEVEL_ENUM getConfidenceLevel(UriRef uri){
+ return uriRef2enum.get(uri);
+ }
+
+ /**
+ * Getter for the fise:ConfidenceLevel instance for the {@link UriRef}
+ * @param uri the URI string
+ * @return the fise:ConfidenceLevel instance or <code>null</code> if
the
+ * parsed URI is not one of the four defined instances
+ */
+ public static CONFIDENCE_LEVEL_ENUM getConfidenceLevel(String uri){
+ return uri2enum.get(uri);
+ }
+ }
}
Modified:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/resources/fise.owl
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/resources/fise.owl?rev=1354819&r1=1354818&r2=1354819&view=diff
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/resources/fise.owl
(original)
+++
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/resources/fise.owl
Thu Jun 28 05:53:01 2012
@@ -1,20 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
+<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#"
@@ -27,10 +11,10 @@
<rdfs:comment xml:lang="en">The FISE Enhancement Structure</rdfs:comment>
</owl:Ontology>
<owl:Class rdf:about="http://fise.iks-project.eu/ontology/TextAnnotation">
- <rdfs:label xml:lang="en">Text Annotation</rdfs:label>
<rdfs:subClassOf>
<owl:Class rdf:about="http://fise.iks-project.eu/ontology/Enhancement"/>
</rdfs:subClassOf>
+ <rdfs:label xml:lang="en">Text Annotation</rdfs:label>
<rdfs:comment xml:lang="en">A TextAnnotation</rdfs:comment>
</owl:Class>
<owl:Class rdf:about="http://fise.iks-project.eu/ontology/TopicAnnotation">
@@ -40,6 +24,10 @@
<owl:Class rdf:about="http://fise.iks-project.eu/ontology/Enhancement"/>
</rdfs:subClassOf>
</owl:Class>
+ <owl:Class rdf:about="http://fise.iks-project.eu/ontology/ConfidenceLevel">
+ <rdfs:comment xml:lang="en">Class for the four different confidence levels
defined by this ontology (introduced with STANBOL-631)</rdfs:comment>
+ <rdfs:label xml:lang="en">Confidence Level</rdfs:label>
+ </owl:Class>
<owl:Class rdf:about="http://fise.iks-project.eu/ontology/EntityAnnotation">
<rdfs:label xml:lang="en">Entity Annotation</rdfs:label>
<rdfs:comment xml:lang="en">An Entity Annotation</rdfs:comment>
@@ -52,9 +40,9 @@
<rdfs:label xml:lang="en">Enhancement</rdfs:label>
</owl:Class>
<owl:ObjectProperty
rdf:about="http://fise.iks-project.eu/ontology/entity-type">
+ <rdfs:comment xml:lang="en">the types of the referenced
entity</rdfs:comment>
<rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/EntityAnnotation"/>
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
- <rdfs:comment xml:lang="en">the types of the referenced
entity</rdfs:comment>
</owl:ObjectProperty>
<owl:DatatypeProperty
rdf:about="http://fise.iks-project.eu/ontology/entity-label">
<rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/EntityAnnotation"/>
@@ -64,15 +52,22 @@
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:comment xml:lang="en">The end char position of a selection within
the text</rdfs:comment>
<rdfs:label xml:lang="en">end</rdfs:label>
- <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
<rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/TextAnnotation"/>
+ <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
</owl:FunctionalProperty>
<owl:FunctionalProperty
rdf:about="http://fise.iks-project.eu/ontology/start">
- <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
- <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/TextAnnotation"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:comment xml:lang="en">The start char position of a selection within
the text</rdfs:comment>
<rdfs:label xml:lang="en">start</rdfs:label>
+ <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
+ <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/TextAnnotation"/>
+ </owl:FunctionalProperty>
+ <owl:FunctionalProperty
rdf:about="http://fise.iks-project.eu/ontology/confidence-level">
+ <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/Enhancement"/>
+ <rdfs:range
rdf:resource="http://fise.iks-project.eu/ontology/ConfidenceLevel"/>
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
+ <rdfs:label xml:lang="en">confidence level</rdfs:label>
+ <rdfs:comment xml:lang="en">the level of confidence for this enhancement
(introduced by STANBOL-631).</rdfs:comment>
</owl:FunctionalProperty>
<owl:FunctionalProperty
rdf:about="http://fise.iks-project.eu/ontology/extracted-from">
<rdfs:comment xml:lang="en">refers to the ContentItem this Enhancement was
extracted from</rdfs:comment>
@@ -81,30 +76,50 @@
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
</owl:FunctionalProperty>
<owl:FunctionalProperty
rdf:about="http://fise.iks-project.eu/ontology/selected-text">
- <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
- <rdfs:comment xml:lang="en">the selected text</rdfs:comment>
- <rdfs:label xml:lang="en">selected text</rdfs:label>
<rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/TextAnnotation"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
+ <rdfs:label xml:lang="en">selected text</rdfs:label>
+ <rdfs:comment xml:lang="en">the selected text</rdfs:comment>
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
</owl:FunctionalProperty>
<owl:FunctionalProperty
rdf:about="http://fise.iks-project.eu/ontology/entity-reference">
+ <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/EntityAnnotation"/>
+ <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:comment xml:lang="en">links to the URI of the referenced
Entity</rdfs:comment>
<rdfs:label xml:lang="en">entity reference</rdfs:label>
- <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
- <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/EntityAnnotation"/>
</owl:FunctionalProperty>
<owl:FunctionalProperty
rdf:about="http://fise.iks-project.eu/ontology/confidence">
- <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
- <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/Enhancement"/>
+ <rdfs:label xml:lang="en">confidence</rdfs:label>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
+ <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/Enhancement"/>
+ <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
<rdfs:comment xml:lang="en">The confidence of the
enhancement</rdfs:comment>
- <rdfs:label xml:lang="en">confidence</rdfs:label>
</owl:FunctionalProperty>
<owl:FunctionalProperty
rdf:about="http://fise.iks-project.eu/ontology/selection-context">
- <rdfs:label xml:lang="en">selection context</rdfs:label>
<rdfs:comment xml:lang="en">The context of the selected
text.</rdfs:comment>
- <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
- <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/TextAnnotation"/>
+ <rdfs:label xml:lang="en">selection context</rdfs:label>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
+ <rdfs:domain
rdf:resource="http://fise.iks-project.eu/ontology/TextAnnotation"/>
+ <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:FunctionalProperty>
-</rdf:RDF>
\ No newline at end of file
+ <ConfidenceLevel
rdf:about="http://fise.iks-project.eu/ontology/cl-suggestion">
+ <rdfs:comment xml:lang="en">Indicates that an Enhancement is not completly
certain but there are not several options (e.g. Germans -> Germany).
Enhancements with this confidence level might or might not be used for
automatic tagging workflows. However they can be typically suggested to users
(introduced by STANBOL-631)</rdfs:comment>
+ <rdfs:label xml:lang="en">suggestion</rdfs:label>
+ </ConfidenceLevel>
+ <ConfidenceLevel
rdf:about="http://fise.iks-project.eu/ontology/cl-uncertain">
+ <rdfs:label xml:lang="en">uncertain</rdfs:label>
+ <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
+ >Indicating that an Enhancement is rather speculative. Enhancements with
this confidence level can be ignored by most usecases. However they might be
processed by other Enhancements Engines (introduced by
STANBOL-631)</rdfs:comment>
+ </ConfidenceLevel>
+ <ConfidenceLevel
rdf:about="http://fise.iks-project.eu/ontology/cl-ambiguous">
+ <rdfs:comment xml:lang="en">Indicates that an Enhancement is ambiguous
with an other one. To be used in cases where there are several possibilities
but it is likelly that one of those is the correct one (e.g. Paris, Paris
(Texas)).
+Enhancements with this confidence value typically need some kind of manual
disambiguation step (introduced by STANBOL-631)</rdfs:comment>
+ <rdfs:label xml:lang="en">ambiguous</rdfs:label>
+ </ConfidenceLevel>
+ <ConfidenceLevel rdf:about="http://fise.iks-project.eu/ontology/cl-certain">
+ <rdfs:comment xml:lang="en">Indicates that an enhancement is very certain
AND also not ambiguous. Enhancements with this confidence level can be usually
accepped by annotation workfolws without manuall validation of resutls
(introduced by STANBOL-631)</rdfs:comment>
+ <rdfs:label xml:lang="en">Certain</rdfs:label>
+ </ConfidenceLevel>
+</rdf:RDF>
+
+<!-- Created with Protege (with OWL Plugin 3.4, Build 128)
http://protege.stanford.edu -->
Modified:
incubator/stanbol/trunk/enhancer/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java?rev=1354819&r1=1354818&r2=1354819&view=diff
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java
(original)
+++
incubator/stanbol/trunk/enhancer/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java
Thu Jun 28 05:53:01 2012
@@ -48,6 +48,7 @@ import org.apache.stanbol.enhancer.servi
import org.apache.stanbol.enhancer.servicesapi.rdf.OntologicalClasses;
import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
import org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses;
+import
org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.CONFIDENCE_LEVEL_ENUM;
public class EnhancementStructureHelper {
@@ -497,6 +498,27 @@ public class EnhancementStructureHelper
}
assertFalse("Only a single dc:type value is allowed!",
dcTypeIterator.hasNext());
}
+ //validate the fise:confidence-value introduced by STANBOL-631
+ Iterator<Triple> confidenceLevelIterator = enhancements.filter(
+ enhancement, Properties.ENHANCER_CONFIDENCE_LEVEL, null);
+ Resource expectedConfidenceValue =
expectedValues.get(Properties.ENHANCER_CONFIDENCE_LEVEL);
+ if(confidenceLevelIterator.hasNext()){
+ Resource confidenceLevelResource =
confidenceLevelIterator.next().getObject();
+ assertTrue("fise:confidence-level values MUST BE URIs but found
"+confidenceLevelResource,
+ confidenceLevelResource instanceof UriRef);
+ assertNotNull("The fise:confidence-level value MUST BE one of the
four "
+ + "values defined in the ontology! (found: "+
confidenceLevelResource
+ + " | enhancement " + enhancement+")",
+
CONFIDENCE_LEVEL_ENUM.getConfidenceLevel((UriRef)confidenceLevelResource));
+ assertFalse("The fise:confidence-level property is functional and
MUST "
+ + "HAVE only a single value (enhancement " +
+ enhancement+")!",confidenceLevelIterator.hasNext());
+ } else {
+ assertNull("fise:confidence-level "+expectedConfidenceValue
+ + "expected for Enhancement "+enhancement
+ + "but no 'fise:confidence-level' value present!",
expectedConfidenceValue);
+ }
+
}
/**
* Validates all fise:TopicAnnotations contained by the parsed enhancements