You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2012/05/16 11:44:41 UTC

svn commit: r1339092 - /incubator/stanbol/branches/celi-enhancement-engines/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java

Author: rwesten
Date: Wed May 16 09:44:41 2012
New Revision: 1339092

URL: http://svn.apache.org/viewvc?rev=1339092&view=rev
Log:
STANBOL-583: Lemmatizer engine now create valid enhancements. We should create an own issue discussion how to represent Lemmas and Morphological features within the Enhancement Structure.

Details:

LemmatizerEngine 

* added extensive validation of the created enhancements
* corrected generation of the enhancements to confirm to the rules
* improved the HTTP client to stream the request data (similar to the HTTP client of the NER engine)

Added a Utils class 

* calculating the fise:selection-context (as it is used for NER and the Lemmatizer Engine (might be even a candidate to move that to the EnhancementEngineHelper utility
* creating a POST request (used by all **ClientHTTP classes)


EnhancementStructureTest:

 * improved messages provided by assertions (to make debuging easier)
 * removed assertion that at least a single TextAnnotation MUST BE present when calling validateAllTextAnnotations. This allows to use this method to ensure that no TextAnnotations are present (makes it consistent with validateAllEntityAnnotations)

Modified:
    incubator/stanbol/branches/celi-enhancement-engines/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java

Modified: incubator/stanbol/branches/celi-enhancement-engines/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java?rev=1339092&r1=1339091&r2=1339092&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/generic/test/src/main/java/org/apache/stanbol/enhancer/test/helper/EnhancementStructureHelper.java Wed May 16 09:44:41 2012
@@ -58,7 +58,8 @@ public class EnhancementStructureHelper 
         Iterator<Triple> textAnnotationIterator = enhancements.filter(null,
                 RDF_TYPE, ENHANCER_TEXTANNOTATION);
         // test if a textAnnotation is present
-        assertTrue(textAnnotationIterator.hasNext());
+        //assertTrue(textAnnotationIterator.hasNext()); 
+        //  -> this might be used to test that there are no TextAnnotations
         int textAnnotationCount = 0;
         while (textAnnotationIterator.hasNext()) {
             UriRef textAnnotation = (UriRef) textAnnotationIterator.next().getSubject();
@@ -85,16 +86,18 @@ public class EnhancementStructureHelper 
         Iterator<Triple> selectedTextIterator = enhancements.filter(textAnnotation,
                 ENHANCER_SELECTED_TEXT, null);
         // check if the selected text is added
-        assertTrue("TextAnnotations MUST have a fise:selected-text value",selectedTextIterator.hasNext());
+        assertTrue("TextAnnotations MUST have a fise:selected-text value (uri: "+textAnnotation+")",
+            selectedTextIterator.hasNext());
         // test if the selected text is part of the TEXT_TO_TEST
         Resource selectedTextResource = selectedTextIterator.next().getObject();
-        assertTrue("fise:selected-text MUST BE of type PlainLiteral",selectedTextResource instanceof PlainLiteral);
+        assertTrue("fise:selected-text MUST BE of type PlainLiteral (uri: "+textAnnotation+")",
+            selectedTextResource instanceof PlainLiteral);
         Literal selectedText = (Literal)selectedTextResource;
         assertTrue("The parsed content MUST contain the fise:selected-text value '"
-            +selectedText.getLexicalForm()+"'!",content.contains(selectedText.getLexicalForm()));
+            +selectedText.getLexicalForm()+"' (uri: "+textAnnotation+")!",content.contains(selectedText.getLexicalForm()));
         Resource expectedSelectedText = expectedValues.get(ENHANCER_SELECTED_TEXT);
         if(expectedSelectedText != null){
-            assertEquals("The fise:selected-text is not the expected value "+expectedSelectedText+"!",
+            assertEquals("The fise:selected-text is not the expected value "+expectedSelectedText+" (uri: "+textAnnotation+")!",
                 expectedSelectedText, selectedText);
         }
         Resource selectionContextResource;
@@ -104,7 +107,8 @@ public class EnhancementStructureHelper 
         if(selectionContextIterator.hasNext()) { //context is optional
             // test if the selected text is part of the TEXT_TO_TEST
             selectionContextResource = selectionContextIterator.next().getObject();
-            assertTrue("The fise:selection-context MUST BE of type PlainLiteral",selectionContextResource instanceof PlainLiteral);
+            assertTrue("The fise:selection-context MUST BE of type PlainLiteral (uri: "+textAnnotation+")",
+                selectionContextResource instanceof PlainLiteral);
             //check that the content contains the context
             assertTrue("The fise:selection-context MUST BE contained in the Content | context= "+ selectionContextResource,
             content.contains(((Literal)selectionContextResource).getLexicalForm()));
@@ -129,26 +133,26 @@ public class EnhancementStructureHelper 
         TypedLiteral startPosLiteral;
         TypedLiteral endPosLiteral;
         if(startPosIterator.hasNext()){
-            assertNotNull("If fise:start is present the fise:selection-context MUST also be present!",
+            assertNotNull("If fise:start is present the fise:selection-context MUST also be present (uri: "+textAnnotation+")!",
                 selectionContextResource);
             Resource resource = startPosIterator.next().getObject();
             //only a single start position is supported
-            assertFalse("fise:start MUST HAVE only a single value!",startPosIterator.hasNext());
-            assertTrue("fise:start MUST be a typed Literal!",resource instanceof TypedLiteral);
+            assertFalse("fise:start MUST HAVE only a single value (uri: "+textAnnotation+")!",startPosIterator.hasNext());
+            assertTrue("fise:start MUST be a typed Literal (uri: "+textAnnotation+")!",resource instanceof TypedLiteral);
             startPosLiteral = (TypedLiteral) resource;
-            assertEquals("fise:start MUST use xsd:int as data type",XSD.int_, startPosLiteral.getDataType());
+            assertEquals("fise:start MUST use xsd:int as data type (uri: "+textAnnotation+")",XSD.int_, startPosLiteral.getDataType());
             resource = null;
             Integer start = LiteralFactory.getInstance().createObject(Integer.class, startPosLiteral);
             assertNotNull("Unable to parse Integer from TypedLiteral "+startPosLiteral,start);
             //now get the end
             //end must be defined if start is present
-            assertTrue("If fise:start is present also fise:end MUST BE defined!",endPosIterator.hasNext());
+            assertTrue("If fise:start is present also fise:end MUST BE defined (uri: "+textAnnotation+")!",endPosIterator.hasNext());
             resource = endPosIterator.next().getObject();
             //only a single end position is supported
-            assertFalse("fise:end MUST HAVE only a single value!",endPosIterator.hasNext());
-            assertTrue("fise:end values MUST BE TypedLiterals",resource instanceof TypedLiteral);
+            assertFalse("fise:end MUST HAVE only a single value (uri: "+textAnnotation+")!",endPosIterator.hasNext());
+            assertTrue("fise:end values MUST BE TypedLiterals (uri: "+textAnnotation+")",resource instanceof TypedLiteral);
             endPosLiteral = (TypedLiteral) resource;
-            assertEquals("fise:end MUST use xsd:int as data type",XSD.int_, endPosLiteral.getDataType());
+            assertEquals("fise:end MUST use xsd:int as data type (uri: "+textAnnotation+")",XSD.int_, endPosLiteral.getDataType());
             resource = null;
             Integer end = LiteralFactory.getInstance().createObject(Integer.class, endPosLiteral);
             assertNotNull("Unable to parse Integer from TypedLiteral "+endPosLiteral,end);