On 02/04/2014 06:10 PM, [email protected] wrote:
@@ -51,8 +55,13 @@ public class SentenceSampleStreamFactory
CmdLineUtil.checkInputFile("Data", params.getData());
FileInputStream sampleDataIn = CmdLineUtil.openInFile(params.getData());
- ObjectStream<String> lineStream = new PlainTextByLineStream(sampleDataIn.getChannel(),
- params.getEncoding());
+ ObjectStream<String> lineStream=null;
+ try {
+ lineStream = new PlainTextByLineStream(new
MockInputStreamFactory(sampleDataIn),
+params.getEncoding());
+ } catch (IOException ex) {
+
Logger.getLogger(SentenceSampleStreamFactory.class.getName()).log(Level.SEVERE,
null, ex);
+ }
return new SentenceSampleStream(lineStream);
}
<SNIP>
/**
* Factory producing OpenNLP {@link TokenSampleStream}s.
@@ -38,7 +41,7 @@ public class TokenSampleStreamFactory ex
public static void registerFactory() {
StreamFactoryRegistry.registerFactory(TokenSample.class,
- StreamFactoryRegistry.DEFAULT_FORMAT, new
TokenSampleStreamFactory(Parameters.class));
+ StreamFactoryRegistry.DEFAULT_FORMAT, new
TokenSampleStreamFactory(Parameters.class));
}
protected <P> TokenSampleStreamFactory(Class<P> params) {
@@ -51,8 +54,13 @@ public class TokenSampleStreamFactory ex
CmdLineUtil.checkInputFile("Data", params.getData());
FileInputStream sampleDataIn = CmdLineUtil.openInFile(params.getData());
- ObjectStream<String> lineStream = new PlainTextByLineStream(sampleDataIn.getChannel(),
- params.getEncoding());
+ ObjectStream<String> lineStream = null;
+ try {
+ lineStream = new PlainTextByLineStream(new
MockInputStreamFactory(sampleDataIn),
+ params.getEncoding());
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
We need to be careful here with the error handling.
It is always good to see how things worked before. In the previous
version a TerminateToolException was thrown in case
the stream couldn't be opened. I suggest that we keep that way of
handling it. Anway, what ever we decide, we should do
it consistently across the code base.
Jörn