opennlp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörn Kottmann (JIRA) <>
Subject [jira] Commented: (OPENNLP-99) EventStream should extend Iterator<Event>
Date Wed, 26 Jan 2011 18:40:44 GMT


Jörn Kottmann commented on OPENNLP-99:

One of the big issues we have currently with the EventStream is that it cannot throw an exception
when something goes wrong. Since it is a requirement to read the data from disk, there is
always a potential for failures. For me it seems not possible to implement this nicely with
an Iterator. In the opennlp tools project we introduced the ObjectStream to circumvent these

> EventStream should extend Iterator<Event>
> -----------------------------------------
>                 Key: OPENNLP-99
>                 URL:
>             Project: OpenNLP
>          Issue Type: New Feature
>          Components: Maxent
>    Affects Versions: maxent-3.0.0-sourceforge
>            Reporter: Steven Bethard
> [As requested, brought over from Sourceforge.]
> Conceptually, EventStream is just an Iterator<Event>. You would get better interoperability
with other Java libraries if EventStream were declared as such. If you didn't care about backwards
compatibility, I'd say just get rid of EventStream entirely and use Iterator<Event>
everywhere instead.
> If you care about backwards compatibility, you could at least declare AbstractEventStream
as implementing Iterator<Event> - it declares all of hasNext(), next() and remove().
I believe that shouldn't break anything, and should make all the current EventStream implementations
into Iterator<Event>s.
> Why do I want this? Because, when using OpenNLP maxent from Scala, if a RealValueFileEventStream
were an Iterator<Event>, I could write:
>   for (event <- stream) {
>     ...
>   }
> But since it's not, I instead have to wrap it in an Iterator:
>   val events = new Iterator[Event] {
>     def hasNext = stream.hasNext
>     def next =
>   }
>   for (event <- events) {
>     ...
>   }
> Or write the while loop version:
>   while (stream.hasNext) {
>     val event =
>     ...
>   }

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message