Skip to content

Commit

Permalink
OPENNLP-1619 - Fix possible NPE for PerformanceMonitor in *Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
rzo1 committed Oct 10, 2024
1 parent ef0a82f commit eb777d2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ public void run(String[] args) {

ChunkerME chunker = new ChunkerME(model);

PerformanceMonitor perfMon = null;
PerformanceMonitor perfMon = new PerformanceMonitor("sent");

try (ObjectStream<String> lineStream = new PlainTextByLineStream(
new SystemInputStreamFactory(), SystemInputStreamFactory.encoding())) {
perfMon = new PerformanceMonitor("sent");
perfMon.start();
String line;
while ((line = lineStream.read()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ public void run(String[] args) {

Parser parser = ParserFactory.create(model, beamSize, advancePercentage);

PerformanceMonitor perfMon = null;
PerformanceMonitor perfMon = new PerformanceMonitor("sent");
try (ObjectStream<String> lineStream = new PlainTextByLineStream(
new SystemInputStreamFactory(), SystemInputStreamFactory.encoding())) {

perfMon = new PerformanceMonitor("sent");
perfMon.start();
String line;
while ((line = lineStream.read()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ public void run(String[] args) {

POSTaggerME tagger = new POSTaggerME(model);

PerformanceMonitor perfMon = null;
PerformanceMonitor perfMon = new PerformanceMonitor("sent");

try (ObjectStream<String> lineStream = new PlainTextByLineStream(
new SystemInputStreamFactory(), SystemInputStreamFactory.encoding())) {

perfMon = new PerformanceMonitor("sent");
perfMon.start();
String line;
while ((line = lineStream.read()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ void process() {
ObjectStream<String> untokenizedLineStream;

ObjectStream<String> tokenizedLineStream;
PerformanceMonitor perfMon = null;
PerformanceMonitor perfMon = new PerformanceMonitor("sent");
try {
untokenizedLineStream =
new PlainTextByLineStream(new SystemInputStreamFactory(), SystemInputStreamFactory.encoding());

tokenizedLineStream = new WhitespaceTokenStream(
new TokenizerStream(tokenizer, untokenizedLineStream));

perfMon = new PerformanceMonitor("sent");
perfMon.start();


Expand Down

0 comments on commit eb777d2

Please sign in to comment.