Hi Rupert

Sorry that I could look at your code proposal for the archetype just
now. Thanks for your proposal.

For now I just did a minimum adaptation to the old code. Mainly
because your code depends on the trunk version api and I would like
the archetypes to be released ASAP.

Also I don't really understand where the enhancement is in your code.
It selectes all Uppercase word but IIUC, the code isn't adding any
enhancement to the selection, maybe just add a RDFS:comment "This is
an uppercase word".

I suggest we look at imprroving the example code after the first release.

Cheers,
Reto



On Fri, Jun 28, 2013 at 11:30 AM, Rupert Westenthaler
<rupert.westentha...@gmail.com> wrote:
> I would rather use an example for a very simple "Keyword" extraction
> engine that uses Upper Case words as keywords and writes them as
> fise:TextAnnotations
>
> Here is some basic Code that should work
>
>
>     MGraph m = ci.getMetadata();
>     LiteralFactory lf = LiteralFactory.getInstance();
>     String text = ContentItemHelper.getText(ci.getBlob());
>     String delims = " -";
>     StringTokenizer tokens = new StringTokenizer(text,delims,true);
>     int offset = 0;
>     int keywordStart = -1;
>     int keywordEnd = -1;
>     while(tokens.hasMoreElements()){
>         String token = tokens.nextToken();
>         if(token.length() == 1 && delims.indexOf(token.charAt(0)) >= 0){
>             offset++;
>         } else if(Character.isUpperCase(token.codePointAt(0))){ //a real word
>             if(keywordStart < 0){
>                 keywordStart = offset;
>             }
>             keywordEnd = offset + token.length();
>         } else { //not a keyword
>             if(keywordStart > 0){ //write out a keyword
>                 String keyword = text.substring(keywordStart,keywordEnd);
>                 String context = EnhancementEngineHelper.getSelectionContext(
>                     text, keyword,keywordStart);
>                 UriRef ta =
> EnhancementEngineHelper.createTextEnhancement(ci, this);
>                 m.add(new TripleImpl(ta, Properties.ENHANCER_START,
>                     lf.createTypedLiteral(keywordStart)));
>                 m.add(new TripleImpl(ta, Properties.ENHANCER_END,
>                     lf.createTypedLiteral(keywordEnd)));
>                 m.add(new TripleImpl(ta, Properties.ENHANCER_SELECTED_TEXT,
>                     new PlainLiteralImpl(keyword)));
>                 m.add(new TripleImpl(ta, 
> Properties.ENHANCER_SELECTION_CONTEXT,
>                     new PlainLiteralImpl(context)));
>                 m.add(new TripleImpl(ta, Properties.ENHANCER_CONFIDENCE,
>                     lf.createTypedLiteral(1.0f))); //we are very confident ^
>                 //reset
>                 keywordStart = -1;
>                 keywordEnd = -1;
>             }
>         }
>     }
>
> best
> Rupert
>
>
> On Fri, Jun 28, 2013 at 9:58 AM, Reto Bachmann-Gmür <r...@wymiwyg.com> wrote:
>> Hi Rupert
>>
>>> I do not like this example. For this I would probably use a simple
>>> triple from the URI of the ContentItem that notes the length of the
>>> text as a value.
>>
>> Well yeah but it should be an example for an enhancer.  A simple one but
>> still a well behaving one.  I understand text annotation is the wrong one
>> to add a comment to the content item as a whole. Which one would be the
>> right one?
>>
>> Cheers,
>> Reto
>>
>> For a fise:TextAnnotation you should set the
>>> fise:start/fise:end as well as the fise:selected-text
>>>
>>> best
>>> Rupert
>>>
>>> > Cheers,
>>> > Reto
>>> >
>>> >
>>> > On Thu, Jun 20, 2013 at 3:18 AM, Reto Bachmann-Gmür <r...@wymiwyg.com
>>>wrote:
>>> >
>>> >> Hi Rupert
>>> >>
>>> >> Thanks, this explains it.
>>> >>
>>> >> In the archetype generated example there's following code:
>>> >>
>>> >>             UriRef textAnnotation =
>>> >>> EnhancementEngineHelper.createTextEnhancement(ci, this);
>>> >>>             metadata.add(new TripleImpl(textAnnotation, RDFS.comment,
>>> >>>                     new PlainLiteralImpl("A text of " +
>> content.length()
>>> >>> + " charaters")));
>>> >>>
>>> >>
>>> >> I guess TextEnhancement is the wrong type for such a comment on the
>> text
>>> >> as a whole. Which type shold be used instead?
>>> >>
>>> >> Cheers,
>>> >> Reto
>>> >>
>>> >>
>>> >> On Wed, Jun 19, 2013 at 2:39 PM, Rupert Westenthaler <
>>> >> rupert.westentha...@gmail.com> wrote:
>>> >>
>>> >>> Hi Reto,
>>> >>>
>>> >>> Based on the source of "ContentItemResource" this happens if an
>>> >>> fise:TextAnnotation does not have a fise:selected-text nor a dc:type
>>> >>> value. Up to now there where no such fise:TextAnnotation created by
>>> >>> any engine. But I guess that your Engine does exactly that.
>>> >>>
>>> >>> No Idea what the UI should use as label for the mention in such cases
>>> >>> but causing a NPE ( by calling extractLabel(NULL) in line 590) is
>>> >>> probably not the best Idea
>>> >>>
>>> >>> best
>>> >>> Rupert
>>> >>>
>>> >>> On Wed, Jun 19, 2013 at 1:26 PM, Reto Bachmann-Gmür <r...@apache.org>
>>> >>> wrote:
>>> >>> > Hello
>>> >>> >
>>> >>> > After deploying a new enhancement engine created from the archetype
>> I'm
>>> >>> > getting the exception below for chains that include the enhancer.
>> I'm
>>> >>> using
>>> >>> > the latest trunk version both for the Stanbol instance as well as
>> for
>>> >>> the
>>> >>> > archetype. Any idea what's causing this?
>>> >>> >
>>> >>> > Cheers,
>>> >>> > Reto
>>> >>> >
>>> >>> > [java] WARNING: A servlet request, to the URI
>>> >>> > http://localhost:8080/enhancer/chain/all-active, contains form
>>> >>> parameters
>>> >>> > in the request body but the request body has been consumed by the
>>> >>> servlet
>>> >>> > or a servlet filter accessing the request parameters. Only resource
>>> >>> methods
>>> >>> > using @FormParam will work as expected. Resource methods consuming
>> the
>>> >>> > request body by other means will not work as expected.
>>> >>> >      [java] Jun 19, 2013 12:18:14 PM
>>> >>> > com.sun.jersey.spi.container.ContainerResponse
>>> >>> mapMappableContainerException
>>> >>> >      [java] SEVERE: The RuntimeException could not be mapped to a
>>> >>> response,
>>> >>> > re-throwing to the HTTP container
>>> >>> >      [java] java.lang.NullPointerException
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.enhancer.jersey.resource.ContentItemResource.extractLabel(ContentItemResource.java:280)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.enhancer.jersey.resource.ContentItemResource$EntityExtractionSummary.<init>(ContentItemResource.java:590)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.enhancer.jersey.resource.ContentItemResource.initOccurrences(ContentItemResource.java:398)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.enhancer.jersey.resource.ContentItemResource.<init>(ContentItemResource.java:191)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.enhancer.jersey.resource.AbstractEnhancerUiResource.enhanceFromForm(AbstractEnhancerUiResource.java:131)
>>> >>> >      [java]     at
>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>> >>> > Method)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> >>> >      [java]     at java.lang.reflect.Method.invoke(Method.java:601)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
>>> >>> >      [java]     at
>>> >>> > javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.commons.httpqueryheaders.impl.QueryHeadersFilter.doFilter(QueryHeadersFilter.java:75)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:78)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.commons.web.resources.ResourceServingFilter.doFilterHttp(ResourceServingFilter.java:148)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.commons.web.resources.ResourceServingFilter.doFilter(ResourceServingFilter.java:91)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.commons.security.auth.AuthenticatingFilter$1.run(AuthenticatingFilter.java:163)
>>> >>> >      [java]     at
>> java.security.AccessController.doPrivileged(Native
>>> >>> > Method)
>>> >>> >      [java]     at
>>> >>> > javax.security.auth.Subject.doAsPrivileged(Subject.java:536)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.stanbol.commons.security.auth.AuthenticatingFilter.doFilter(AuthenticatingFilter.java:159)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>>> >>> >      [java]     at
>>> >>> > javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>> >>> >      [java]     at
>>> >>> >
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>>> >>> >      [java]     at
>>> >>> >
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>>> >>> >      [java]     at
>>> >>> >
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>>> >>> >      [java]     at
>>> >>> >
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>> >>> >      [java]     at
>>> >>> >
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>> >>> >      [java]     at org.mortbay.jetty.Server.handle(Server.java:326)
>>> >>> >      [java]     at
>>> >>> >
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>>> >>> >      [java]     at
>>> >>> > org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>>> >>> >      [java]     at
>>> >>> > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
>>> >>> >      [java]     at
>>> >>> > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>>> >>> >      [java]     at
>>> >>> >
>>> >>>
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>>> >>> >      [java]
>>> >>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> | Rupert Westenthaler             rupert.westentha...@gmail.com
>>> >>> | Bodenlehenstraße 11                             ++43-699-11108907
>>> >>> | A-5500 Bischofshofen
>>> >>>
>>> >>
>>> >>
>>>
>>>
>>>
>>> --
>>> | Rupert Westenthaler             rupert.westentha...@gmail.com
>>> | Bodenlehenstraße 11                             ++43-699-11108907
>>> | A-5500 Bischofshofen
>
>
>
> --
> | Rupert Westenthaler             rupert.westentha...@gmail.com
> | Bodenlehenstraße 11                             ++43-699-11108907
> | A-5500 Bischofshofen

Reply via email to