Hi John,

When implementing you own Engine it is highly recommended to use the
EnhancementEngineHelper to write unit tests that do validate the
Enhancements your Engine creates. If our engine passes those tests it
should also work fine with the client. Adding additional information
(e.g. by using the rdfs:comment property) is absolutely fine. My guess
is that the client breaks because for a fise:TextAnnotation some
property are expected and their fore the client might run into a NPE.

Just look in existing Stanbol Engines for examples (e.g. [1])

A typical Test will look like follows

    public static final String TEXT = "The text for testing the engine";

    private EnhancementEngine engine;

    public static ContentItem wrapAsContentItem(final String id,
            final String text, String language) throws IOException {
        ContentItem ci =  ciFactory.createContentItem(new
UriRef(id),new StringSource(text));
        if(language != null){
          ci.getMetadata().add(new TripleImpl(ci.getUri(),
DC_LANGUAGE, new PlainLiteralImpl(language)));
        }
       return ci;
    }

    @Before
    public void initEngine() throws IOException {
        engine = new EngineToTest(...);
    }

    @Test
    public void testComputeEnhancements()
            throws EngineException, IOException {
        ContentItem ci =
wrapAsContentItem("urn:test:content-item:single:sentence", TEXT,"en");
        engine.computeEnhancements(ci);
        Map<UriRef,Resource> expectedValues = new HashMap<UriRef,Resource>();
        expectedValues.put(Properties.ENHANCER_EXTRACTED_FROM, ci.getUri());
        expectedValues.put(Properties.DC_CREATOR,
LiteralFactory.getInstance().createTypedLiteral(nerEngine.getClass().getName()));
        //adding null as expected for confidence makes it a required property
        expectedValues.put(Properties.ENHANCER_CONFIDENCE, null);
        MGraph g = ci.getMetadata();
        int textAnnotationCount =
EnhancementStructureHelper.validateAllTextAnnotations(g,SINGLE_SENTENCE,expectedValues);
        //Lets assume you expect 3 TextAnnotations as result of
enhancing the TEXT
        assertEquals(3, textAnnotationCount);

        //NOTE: Their are other validation methods for testing
EntityAnnotation and TopicAnnotation.
    }


best
Rupert

[1] 
http://svn.apache.org/repos/asf/stanbol/trunk/enhancement-engines/opennlp/opennlp-ner/src/test/java/org/apache/stanbol/enhancer/engines/opennlp/impl/TestNamedEntityExtractionEnhancementEngine.java

On Wed, May 13, 2015 at 7:17 PM,  <john.2.crowt...@bt.com> wrote:
> Hello All,
>
> I have been building an enhancer engine which I want to add to a one of the 
> default chains  dbpedia-proper-noun.
>
> I am using the java Stanbol client to query the Stanbol server and extract 
> places, names and organisations.
>
> When I add my enhancement engine to the chain I get a null pointer in 
> javax.ws.rs.ProcessingException on the client side during the read entity 
> method .
>
> If I comment out the engine metadata editing below, my client software works 
> fine with the extra engine on the chain.
>
> UriRef textAnnotation = EnhancementEngineHelper.createTextEnhancement(ci, 
> this);
> metadata.add(new TripleImpl(textAnnotation, DCTERMS.type,
>         new UriRef("http://example.org/ontology/LengthEnhancement";)));
>
> metadata.add(new TripleImpl(textAnnotation, RDFS.comment,
>         new PlainLiteralImpl(" --- this is where I want to add information 
> ----")));
>
>
> How can I add information to the metadata without breaking my client ?
>
> Best Regards,
>
> John Crowther
>
>



-- 
| Rupert Westenthaler             rupert.westentha...@gmail.com
| Bodenlehenstraße 11                              ++43-699-11108907
| A-5500 Bischofshofen
| REDLINK.CO 
..........................................................................
| http://redlink.co/

Reply via email to