You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jz...@apache.org on 2022/04/22 11:41:47 UTC

[opennlp] branch master updated: OPENNLP-1368: Removing model major version number check. (#415)

This is an automated email from the ASF dual-hosted git repository.

jzemerick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/opennlp.git


The following commit(s) were added to refs/heads/master by this push:
     new 9ccab9ee OPENNLP-1368: Removing model major version number check. (#415)
9ccab9ee is described below

commit 9ccab9eeac00f1a130f937b24df83794a71b579c
Author: Jeff Zemerick <je...@mtnfog.com>
AuthorDate: Fri Apr 22 07:41:43 2022 -0400

    OPENNLP-1368: Removing model major version number check. (#415)
    
    * OPENNLP-1368: Removing model major version number check.
    
    * OPENNLP-1368: Checking for version 1 model.
---
 opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java | 6 ++----
 .../src/test/java/opennlp/tools/chunker/ChunkerModelTest.java       | 2 ++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java b/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java
index 8c3d7168..a345417c 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java
@@ -416,10 +416,8 @@ public abstract class BaseModel implements ArtifactProvider, Serializable {
 
       // Version check is only performed if current version is not the dev/debug version
       if (!Version.currentVersion().equals(Version.DEV_VERSION)) {
-        // Major and minor version must match, revision might be
-        // this check allows for the use of models of n minor release behind current minor release
-        if (Version.currentVersion().getMajor() != version.getMajor() ||
-            Version.currentVersion().getMinor() - 4 > version.getMinor()) {
+        // Support OpenNLP 1.x models.
+        if (version.getMajor() != 1) {
           throw new InvalidFormatException("Model version " + version + " is not supported by this ("
               + Version.currentVersion() + ") version of OpenNLP!");
         }
diff --git a/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerModelTest.java b/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerModelTest.java
index 85afc53b..0d6b513f 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerModelTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkerModelTest.java
@@ -43,6 +43,7 @@ public class ChunkerModelTest {
   @Test
   public void test170DefaultFactory() throws Exception {
 
+    // This is an OpenNLP 1.x model. It should load with OpenNLP 2.x.
     Assert.assertNotNull(
         new ChunkerModel(this.getClass().getResourceAsStream("chunker170default.bin")));
 
@@ -51,6 +52,7 @@ public class ChunkerModelTest {
   @Test
   public void test180CustomFactory() throws Exception {
 
+    // This is an OpenNLP 1.x model. It should load with OpenNLP 2.x.
     Assert.assertNotNull(
         new ChunkerModel(this.getClass().getResourceAsStream("chunker180custom.bin")));