From 1fdb303cdb734c3a91a3ed30adde255c94f78eab Mon Sep 17 00:00:00 2001 From: haozhew4 Date: Thu, 16 Nov 2023 21:58:23 -0600 Subject: [PATCH 1/3] fix fnlp-demo --- .../src/main/java/org/fnlp/data/reader/SimpleFileReader.java | 3 +++ .../src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java | 2 +- .../src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java | 2 +- .../src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fnlp-core/src/main/java/org/fnlp/data/reader/SimpleFileReader.java b/fnlp-core/src/main/java/org/fnlp/data/reader/SimpleFileReader.java index f6536c0..db4e253 100644 --- a/fnlp-core/src/main/java/org/fnlp/data/reader/SimpleFileReader.java +++ b/fnlp-core/src/main/java/org/fnlp/data/reader/SimpleFileReader.java @@ -113,6 +113,9 @@ public boolean hasNext() { try { while(true){ + if (reader==null) { + return false; + } content = reader.readLine(); line++; if(content==null){ diff --git a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java index 2a0b5d1..16aa68f 100644 --- a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java +++ b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java @@ -99,6 +99,6 @@ public static void main(String[] args) throws Exception { System.out.println("Total Time: " + (end - start)); System.out.println("End!"); (new File(modelFile)).deleteOnExit(); - System.exit(0); + } } \ No newline at end of file diff --git a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java index b79a71a..9947f18 100644 --- a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java +++ b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java @@ -96,6 +96,6 @@ public static void main(String[] args) throws Exception { System.out.println("Total Time: " + (end - start)); System.out.println("End!"); (new File(modelFile)).deleteOnExit(); - System.exit(0); + } } \ No newline at end of file diff --git a/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java b/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java index 3ddbaa2..6d6cd25 100644 --- a/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java +++ b/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java @@ -101,6 +101,6 @@ public static void main(String[] args) throws Exception { System.out.println("Total Time: " + (end - start)); System.out.println("End!"); (new File(modelFile)).deleteOnExit(); - System.exit(0); + } } \ No newline at end of file From 67d1f58ef81a91f0f90d91d84173fcb274d28122 Mon Sep 17 00:00:00 2001 From: Andy Wu <70547760+Einsteinnnnn@users.noreply.github.com> Date: Thu, 16 Nov 2023 21:59:55 -0600 Subject: [PATCH 2/3] Update HierClassifierUsage1.java --- .../fnlp/demo/ml/HierClassifierUsage1.java | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java index 16aa68f..02b997d 100644 --- a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java +++ b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java @@ -1,22 +1,22 @@ -/** -* This file is part of FNLP (formerly FudanNLP). -* -* FNLP is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* FNLP is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with FudanNLP. If not, see . -* -* Copyright 2009-2014 www.fnlp.org. All rights reserved. -*/ - +/** +* This file is part of FNLP (formerly FudanNLP). +* +* FNLP is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* FNLP is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with FudanNLP. If not, see . +* +* Copyright 2009-2014 www.fnlp.org. All rights reserved. +*/ + package org.fnlp.demo.ml; @@ -99,6 +99,5 @@ public static void main(String[] args) throws Exception { System.out.println("Total Time: " + (end - start)); System.out.println("End!"); (new File(modelFile)).deleteOnExit(); - } -} \ No newline at end of file +} From e907273ceba22acb2284b42b93d27e101c90f0a4 Mon Sep 17 00:00:00 2001 From: haozhew4 Date: Thu, 16 Nov 2023 22:06:44 -0600 Subject: [PATCH 3/3] fix eol --- .../fnlp/demo/ml/HierClassifierUsage1.java | 40 +++++++++---------- .../fnlp/demo/ml/HierClassifierUsage2.java | 1 - .../org/fnlp/demo/ml/SimpleClassifier2.java | 1 - 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java index 02b997d..982ba55 100644 --- a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java +++ b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage1.java @@ -1,22 +1,22 @@ -/** -* This file is part of FNLP (formerly FudanNLP). -* -* FNLP is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* FNLP is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with FudanNLP. If not, see . -* -* Copyright 2009-2014 www.fnlp.org. All rights reserved. -*/ - +/** +* This file is part of FNLP (formerly FudanNLP). +* +* FNLP is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* FNLP is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with FudanNLP. If not, see . +* +* Copyright 2009-2014 www.fnlp.org. All rights reserved. +*/ + package org.fnlp.demo.ml; @@ -100,4 +100,4 @@ public static void main(String[] args) throws Exception { System.out.println("End!"); (new File(modelFile)).deleteOnExit(); } -} +} \ No newline at end of file diff --git a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java index 9947f18..b0195fd 100644 --- a/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java +++ b/fnlp-demo/src/main/java/org/fnlp/demo/ml/HierClassifierUsage2.java @@ -96,6 +96,5 @@ public static void main(String[] args) throws Exception { System.out.println("Total Time: " + (end - start)); System.out.println("End!"); (new File(modelFile)).deleteOnExit(); - } } \ No newline at end of file diff --git a/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java b/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java index 6d6cd25..cdf3ba6 100644 --- a/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java +++ b/fnlp-demo/src/main/java/org/fnlp/demo/ml/SimpleClassifier2.java @@ -101,6 +101,5 @@ public static void main(String[] args) throws Exception { System.out.println("Total Time: " + (end - start)); System.out.println("End!"); (new File(modelFile)).deleteOnExit(); - } } \ No newline at end of file