Class: Omnizip::Algorithms::PPMd7
- Inherits:
-
Omnizip::Algorithm
- Object
- Omnizip::Algorithm
- Omnizip::Algorithms::PPMd7
- Includes:
- Constants
- Defined in:
- lib/omnizip/algorithms/ppmd7.rb,
lib/omnizip/algorithms/ppmd7/model.rb,
lib/omnizip/algorithms/ppmd7/context.rb,
lib/omnizip/algorithms/ppmd7/decoder.rb,
lib/omnizip/algorithms/ppmd7/encoder.rb,
lib/omnizip/algorithms/ppmd7/constants.rb,
lib/omnizip/algorithms/ppmd7/symbol_state.rb
Overview
PPMd7 compression algorithm
PPMd (Prediction by Partial Matching) is a statistical compression algorithm that excels at text compression. It uses context-based prediction to achieve high compression ratios on text files.
This implementation follows the PPMd7 specification as used in 7-Zip.
Defined Under Namespace
Modules: Constants Classes: Context, Decoder, Encoder, Model, SymbolState
Constant Summary
Constants included from Constants
Constants::ALPHABET_SIZE, Constants::BIN_SCALE, Constants::BOT_VALUE, Constants::DEFAULT_MEM_SIZE, Constants::DEFAULT_ORDER, Constants::INIT_ESCAPE_FREQ, Constants::INTERVAL, Constants::INT_BITS, Constants::MAX_FREQ, Constants::MAX_MEM_SIZE, Constants::MAX_ORDER, Constants::MAX_STATES, Constants::MIN_MEM_SIZE, Constants::MIN_ORDER, Constants::PERIOD_BITS, Constants::PROB_TOTAL, Constants::SEE_CONTEXTS, Constants::SUFFIX_CONTEXTS, Constants::TOP_VALUE, Constants::UNIT_ALLOC_SIZE, Constants::UNIT_SIZE
Instance Attribute Summary
Attributes inherited from Omnizip::Algorithm
Class Method Summary collapse
-
.metadata ⇒ AlgorithmMetadata
Algorithm metadata.
Instance Method Summary collapse
-
#compress(input, output, options = {}) ⇒ void
Compress data using PPMd7.
-
#decompress(input, output, options = {}) ⇒ void
Decompress data using PPMd7.
Methods inherited from Omnizip::Algorithm
inherited, #initialize, #with_filter
Constructor Details
This class inherits a constructor from Omnizip::Algorithm
Class Method Details
.metadata ⇒ AlgorithmMetadata
Algorithm metadata
50 51 52 53 54 55 56 57 58 |
# File 'lib/omnizip/algorithms/ppmd7.rb', line 50 def self. Models::AlgorithmMetadata.new.tap do |m| m.name = "ppmd7" m.description = "PPMd7 - Prediction by Partial Matching " \ "for statistical text compression" m.version = "1.0.0" m.supports_streaming = true end end |
Instance Method Details
#compress(input, output, options = {}) ⇒ void
This method returns an undefined value.
Compress data using PPMd7
68 69 70 71 72 73 74 |
# File 'lib/omnizip/algorithms/ppmd7.rb', line 68 def compress(input, output, = {}) input = prepare_input(input) output = prepare_output(output) encoder = PPMd7::Encoder.new(output, ) encoder.encode_stream(input) end |
#decompress(input, output, options = {}) ⇒ void
This method returns an undefined value.
Decompress data using PPMd7
84 85 86 87 88 89 90 91 92 |
# File 'lib/omnizip/algorithms/ppmd7.rb', line 84 def decompress(input, output, = {}) input = prepare_input(input) output = prepare_output(output) decoder = PPMd7::Decoder.new(input, ) result = decoder.decode_stream output.write(result) end |