Debian Codegraph @

morfologik-stemming/src/main/java/morfologik/stemming/ISequenceEncoder.java

raw
1 package morfologik.stemming;
2
3 import java.nio.ByteBuffer;
4
5 /**
6 * The logic of encoding one sequence of bytes relative to another sequence of
7 * bytes. The "base" form and the "derived" form are typically the stem of
8 * a word and the inflected form of a word.
9 *
10 * <p>Derived form encoding helps in making the data for the automaton smaller
11 * and more repetitive (which results in higher compression rates).
12 *
13 * <p>See example implementation for details.
14 */
15 public interface ISequenceEncoder {
16 /**
17 * Encodes <code>target</code> relative to <code>source</code>,
18 * optionally reusing the provided {@link ByteBuffer}.
19 *
20 * @param reuse Reuses the provided {@link ByteBuffer} or allocates a new one if there is not enough remaining space.
21 * @param source The source byte sequence.
22 * @param target The target byte sequence to encode relative to <code>source</code>
23 * @return Returns the {@link ByteBuffer} with encoded <code>target</code>.
24 */
25 public ByteBuffer encode(ByteBuffer reuse, ByteBuffer source, ByteBuffer target);
26
27 /**
28 * Decodes <code>encoded</code> relative to <code>source</code>,
29 * optionally reusing the provided {@link ByteBuffer}.
30 *
31 * @param reuse Reuses the provided {@link ByteBuffer} or allocates a new one if there is not enough remaining space.
32 * @param source The source byte sequence.
33 * @param encoded The {@linkplain #encode previously encoded} byte sequence.
34 * @return Returns the {@link ByteBuffer} with decoded <code>target</code>.
35 */
36 public ByteBuffer decode(ByteBuffer reuse, ByteBuffer source, ByteBuffer encoded);
37
38 /**
39 * The number of encoded form's prefix bytes that should be ignored (needed for separator lookup).
40 * An ugly workaround for GH-85, should be fixed by prior knowledge of whether the dictionary contains tags;
41 * then we can scan for separator right-to-left.
42 *
43 * @see "https://github.com/morfologik/morfologik-stemming/issues/85"
44 */
45 @Deprecated
46 public int prefixBytes();
47 }