Package opennlp.tools.tokenize
Class BPETokenizerFactory.BPEMergesSerializer
java.lang.Object
opennlp.tools.tokenize.BPETokenizerFactory.BPEMergesSerializer
- All Implemented Interfaces:
ArtifactSerializer<List<BPETokenizer.SymbolPair>>
- Enclosing class:
BPETokenizerFactory
static class BPETokenizerFactory.BPEMergesSerializer
extends Object
implements ArtifactSerializer<List<BPETokenizer.SymbolPair>>
An
ArtifactSerializer for BPE merge rules.
Serializes merge rules as a text file with one merge pair per line,
in the format: left right.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate(InputStream in) Creates an artifact from the providedInputStream.voidserialize(List<BPETokenizer.SymbolPair> artifact, OutputStream out) Serializes the merge rules to the givenOutputStream.
-
Constructor Details
-
BPEMergesSerializer
BPEMergesSerializer()
-
-
Method Details
-
create
Description copied from interface:ArtifactSerializerCreates an artifact from the providedInputStream.Note: The
InputStreamremains open.- Specified by:
createin interfaceArtifactSerializer<List<BPETokenizer.SymbolPair>>- Parameters:
in- A valid, openInputStreamready to read from.- Returns:
- A valid
artifact. - Throws:
IOException- Thrown if IO errors occurred during creation.
-
serialize
Serializes the merge rules to the givenOutputStream.Note: This method wraps the provided
OutputStreamin aBufferedWriterand flushes it upon completion, but does not close the underlying stream. The caller is responsible for closingout.- Specified by:
serializein interfaceArtifactSerializer<List<BPETokenizer.SymbolPair>>- Parameters:
artifact- A validartifact.out- A valid, openOutputStreamready to write to.- Throws:
IOException- Thrown if IO errors occurred during serialization.
-