Remove deprecated constructors in Nori (#695)

This commit is contained in:
Tomoko Uchida 2022-02-20 17:40:45 +09:00 committed by GitHub
parent 58fa95deea
commit e7a29c4c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1 additions and 105 deletions

View File

@ -15,7 +15,7 @@ API Changes
* LUCENE-10368: IntTaxonomyFacets has been make pkg-private and serves only as an internal * LUCENE-10368: IntTaxonomyFacets has been make pkg-private and serves only as an internal
implementation detail of taxonomy-faceting. (Greg Miller) implementation 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 New Features
--------------------- ---------------------

View File

@ -33,13 +33,6 @@ import org.apache.lucene.util.IntsRef;
/** Base class for a binary-encoded in-memory dictionary. */ /** Base class for a binary-encoded in-memory dictionary. */
public abstract class BinaryDictionary implements 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 TARGETMAP_FILENAME_SUFFIX = "$targetMap.dat";
public static final String DICT_FILENAME_SUFFIX = "$buffer.dat"; public static final String DICT_FILENAME_SUFFIX = "$buffer.dat";
public static final String POSDICT_FILENAME_SUFFIX = "$posDict.dat"; public static final String POSDICT_FILENAME_SUFFIX = "$posDict.dat";

View File

@ -22,7 +22,6 @@ import java.io.InputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.store.DataInput; import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.InputStreamDataInput; import org.apache.lucene.store.InputStreamDataInput;
@ -39,20 +38,6 @@ public final class ConnectionCosts {
private final ByteBuffer buffer; private final ByteBuffer buffer;
private final int forwardSize; 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. * Create a {@link ConnectionCosts} from an external resource path.
* *

View File

@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.lucene.store.DataInput; import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.InputStreamDataInput; import org.apache.lucene.store.InputStreamDataInput;
import org.apache.lucene.util.IOSupplier; import org.apache.lucene.util.IOSupplier;
@ -47,30 +46,6 @@ public final class TokenInfoDictionary extends BinaryDictionary {
() -> getClassResource(FST_FILENAME_SUFFIX)); () -> 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. * Create a {@link TokenInfoDictionary} from an external resource path.
* *

View File

@ -20,33 +20,12 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
/** Dictionary for unknown-word handling. */ /** Dictionary for unknown-word handling. */
public final class UnknownDictionary extends BinaryDictionary { public final class UnknownDictionary extends BinaryDictionary {
private final CharacterDefinition characterDefinition = CharacterDefinition.getInstance(); 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. * Create a {@link UnknownDictionary} from an external resource path.
* *

View File

@ -26,10 +26,6 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.ko.KoreanTokenizer.DecompoundMode; 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.dict.UserDictionary;
import org.apache.lucene.analysis.ko.tokenattributes.PartOfSpeechAttribute; import org.apache.lucene.analysis.ko.tokenattributes.PartOfSpeechAttribute;
import org.apache.lucene.analysis.ko.tokenattributes.ReadingAttribute; import org.apache.lucene.analysis.ko.tokenattributes.ReadingAttribute;
@ -472,38 +468,6 @@ public class TestKoreanTokenizer extends BaseTokenStreamTestCase {
new int[] {1}); 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 { public void testInterpunct() throws IOException {
assertAnalyzesTo( assertAnalyzesTo(
analyzer, analyzer,