Apache Lucene open-source search software
Remove deprecated constructors in Nori (#695)
Tomoko Uchidae7a29c4c4c10
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 14c590e8781..cd9fd0ac90e 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -15,7 +15,7 @@ API Changes* LUCENE-10368: IntTaxonomyFacets has been make pkg-private and serves only as an internalimplementation detail of taxonomy-faceting. (Greg Miller)-* LUCENE-10400: Remove deprecated dictionary constructors in Kuromoji (Tomoko Uchida)+* LUCENE-10400: Remove deprecated dictionary constructors in Kuromoji and Nori (Tomoko Uchida)New Features---------------------diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/BinaryDictionary.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/BinaryDictionary.javaindex aba6782182b..4d10e520055 100644--- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/BinaryDictionary.java+++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/BinaryDictionary.java@@ -33,13 +33,6 @@ import org.apache.lucene.util.IntsRef;/** Base class for a binary-encoded in-memory dictionary. */public abstract class BinaryDictionary implements Dictionary {- /** Used to specify where (dictionary) resources get loaded from. */- @Deprecated(forRemoval = true, since = "9.1")- public enum ResourceScheme {- CLASSPATH,- FILE- }-public static final String TARGETMAP_FILENAME_SUFFIX = "$targetMap.dat";public static final String DICT_FILENAME_SUFFIX = "$buffer.dat";public static final String POSDICT_FILENAME_SUFFIX = "$posDict.dat";diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/ConnectionCosts.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/ConnectionCosts.javaindex 41dc4aa713a..61579aef845 100644--- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/ConnectionCosts.java+++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/ConnectionCosts.java@@ -22,7 +22,6 @@ import java.io.InputStream;import java.nio.ByteBuffer;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import org.apache.lucene.codecs.CodecUtil;import org.apache.lucene.store.DataInput;import org.apache.lucene.store.InputStreamDataInput;@@ -39,20 +38,6 @@ public final class ConnectionCosts {private final ByteBuffer buffer;private final int forwardSize;- /**- * @param scheme - scheme for loading resources (FILE or CLASSPATH).- * @param resourcePath - where to load resources from, without the ".dat" suffix- */- @Deprecated(forRemoval = true, since = "9.1")- @SuppressWarnings("removal")- public ConnectionCosts(BinaryDictionary.ResourceScheme scheme, String resourcePath)- throws IOException {- this(- scheme == BinaryDictionary.ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + FILENAME_SUFFIX))- : ConnectionCosts::getClassResource);- }-/*** Create a {@link ConnectionCosts} from an external resource path.*diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/TokenInfoDictionary.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/TokenInfoDictionary.javaindex c5182a5123b..1f936b44724 100644--- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/TokenInfoDictionary.java+++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/TokenInfoDictionary.java@@ -21,7 +21,6 @@ import java.io.IOException;import java.io.InputStream;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import org.apache.lucene.store.DataInput;import org.apache.lucene.store.InputStreamDataInput;import org.apache.lucene.util.IOSupplier;@@ -47,30 +46,6 @@ public final class TokenInfoDictionary extends BinaryDictionary {() -> getClassResource(FST_FILENAME_SUFFIX));}- /**- * @param resourceScheme - scheme for loading resources (FILE or CLASSPATH).- * @param resourcePath - where to load resources (dictionaries) from. If null, with CLASSPATH- * scheme only, use this class's name as the path.- */- @Deprecated(forRemoval = true, since = "9.1")- @SuppressWarnings("removal")- public TokenInfoDictionary(ResourceScheme resourceScheme, String resourcePath)- throws IOException {- this(- resourceScheme == ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + TARGETMAP_FILENAME_SUFFIX))- : () -> getClassResource(TARGETMAP_FILENAME_SUFFIX),- resourceScheme == ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + POSDICT_FILENAME_SUFFIX))- : () -> getClassResource(POSDICT_FILENAME_SUFFIX),- resourceScheme == ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + DICT_FILENAME_SUFFIX))- : () -> getClassResource(DICT_FILENAME_SUFFIX),- resourceScheme == ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + FST_FILENAME_SUFFIX))- : () -> getClassResource(FST_FILENAME_SUFFIX));- }-/*** Create a {@link TokenInfoDictionary} from an external resource path.*diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UnknownDictionary.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UnknownDictionary.javaindex 10eb1611b82..f2aa89ee8c5 100644--- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UnknownDictionary.java+++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UnknownDictionary.java@@ -20,33 +20,12 @@ import java.io.IOException;import java.io.InputStream;import java.nio.file.Files;import java.nio.file.Path;-import java.nio.file.Paths;import org.apache.lucene.util.IOUtils;/** Dictionary for unknown-word handling. */public final class UnknownDictionary extends BinaryDictionary {private final CharacterDefinition characterDefinition = CharacterDefinition.getInstance();- /**- * @param scheme scheme for loading resources (FILE or CLASSPATH).- * @param resourcePath where to load resources from; a path, including the file base name without- * extension; this is used to match multiple files with the same base name.- */- @Deprecated(forRemoval = true, since = "9.1")- @SuppressWarnings("removal")- public UnknownDictionary(ResourceScheme scheme, String resourcePath) throws IOException {- super(- scheme == ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + TARGETMAP_FILENAME_SUFFIX))- : () -> getClassResource(TARGETMAP_FILENAME_SUFFIX),- scheme == ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + POSDICT_FILENAME_SUFFIX))- : () -> getClassResource(POSDICT_FILENAME_SUFFIX),- scheme == ResourceScheme.FILE- ? () -> Files.newInputStream(Paths.get(resourcePath + DICT_FILENAME_SUFFIX))- : () -> getClassResource(DICT_FILENAME_SUFFIX));- }-/*** Create a {@link UnknownDictionary} from an external resource path.*diff --git a/lucene/analysis/nori/src/test/org/apache/lucene/analysis/ko/TestKoreanTokenizer.java b/lucene/analysis/nori/src/test/org/apache/lucene/analysis/ko/TestKoreanTokenizer.javaindex 315c876435c..85f87c2ec82 100644--- a/lucene/analysis/nori/src/test/org/apache/lucene/analysis/ko/TestKoreanTokenizer.java+++ b/lucene/analysis/nori/src/test/org/apache/lucene/analysis/ko/TestKoreanTokenizer.java@@ -26,10 +26,6 @@ import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.TokenStream;import org.apache.lucene.analysis.Tokenizer;import org.apache.lucene.analysis.ko.KoreanTokenizer.DecompoundMode;-import org.apache.lucene.analysis.ko.dict.BinaryDictionary.ResourceScheme;-import org.apache.lucene.analysis.ko.dict.ConnectionCosts;-import org.apache.lucene.analysis.ko.dict.TokenInfoDictionary;-import org.apache.lucene.analysis.ko.dict.UnknownDictionary;import org.apache.lucene.analysis.ko.dict.UserDictionary;import org.apache.lucene.analysis.ko.tokenattributes.PartOfSpeechAttribute;import org.apache.lucene.analysis.ko.tokenattributes.ReadingAttribute;@@ -472,38 +468,6 @@ public class TestKoreanTokenizer extends BaseTokenStreamTestCase {new int[] {1});}- // Make sure loading custom dictionaries from classpath works:- @SuppressWarnings("removal")- public void testCustomDictionary() throws Exception {- Tokenizer tokenizer =- new KoreanTokenizer(- newAttributeFactory(),- new TokenInfoDictionary(- ResourceScheme.CLASSPATH, "org/apache/lucene/analysis/ko/dict/TokenInfoDictionary"),- new UnknownDictionary(- ResourceScheme.CLASSPATH, "org/apache/lucene/analysis/ko/dict/UnknownDictionary"),- new ConnectionCosts(- ResourceScheme.CLASSPATH, "org/apache/lucene/analysis/ko/dict/ConnectionCosts"),- readDict(),- DecompoundMode.NONE,- false,- false);- try (Analyzer a =- new Analyzer() {- @Override- protected Analyzer.TokenStreamComponents createComponents(String fieldName) {- return new Analyzer.TokenStreamComponents(tokenizer, tokenizer);- }- }) {- assertTokenStreamContents(- a.tokenStream("foo", "커스텀사전검사"),- new String[] {"커스텀", "사전", "검사"},- new int[] {0, 3, 5},- new int[] {3, 5, 7},- 7);- }- }-public void testInterpunct() throws IOException {assertAnalyzesTo(analyzer,