uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tommaso Teofili <tommaso.teof...@gmail.com>
Subject Re: AnnotationFS.getCoveredText returns null?
Date Thu, 23 Feb 2012 14:14:45 GMT
BTW it looks like this piece of code is prone to error due to incorrect
setting of begin and end.
If I have a text 'abc' and set begin to 0 and end to 5 then I'll have an
error only when I call the getCoveredText() method so I think we should
either check if the input is correct in setters or inside getCoveredText()
to avoid IndexOutOfBoundExceptions generated from the substring method.
Am I right or did I miss something that already prevents that situation?
Tommaso

2012/2/23 Thilo Goetz <twgoetz@gmx.de>

> On 23/02/12 13:33, Jörn Kottmann wrote:
> > Hi all,
> >
> > the CasEditor code assumes that getCoveredText never returns
> > null.
> >
> > Should that always be the case?
> >
> > I have here a CAS with two DocumentAnnotations:
> >
> > 1. The one created by UIMA
> > 2. An ArticleDocumentAnnotation (extends DocumentAnnotation)
> >     where the begin and end indexes are 0
> >
> > The second one returns null when getCoveredText is called
> > (I can do more debugging when needed).
> >
> > Jörn
>
> This is the source code:
>
>  public String getCoveredText() {
>    final CAS casView = this.getView();
>    final String text = casView.getDocumentText();
>    if (text == null) {
>      return null;
>    }
>    return text.substring(getBegin(), getEnd());
>  }
>
> Your ArticleDocumentAnnotation probably belongs to a different
> view or sofa or whatever the right terminology is, which doesn't
> have a document text.
>
> --Thilo
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message