Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26bd4609 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi
Browse files

Reading dictionary containing timestamps in Java Side.

Just skipping historical information fields.

Bug: 11281877
Change-Id: I43d2adaa576b7da11ed3ca54990265dbb6f53b08
parent a454a7b8
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public abstract class AbstractDictDecoder implements DictDecoder {
          throw new UnsupportedFormatException("Unsupported version : " + version);
        }
        // TODO: Remove this field.
        final int optionsFlags = HeaderReader.readOptionFlags(headerBuffer);
        HeaderReader.readOptionFlags(headerBuffer);
        final int headerSize = HeaderReader.readHeaderSize(headerBuffer);
        if (headerSize < 0) {
            throw new UnsupportedFormatException("header size can't be negative.");
@@ -59,8 +59,8 @@ public abstract class AbstractDictDecoder implements DictDecoder {

        final FileHeader header = new FileHeader(headerSize,
                new FusionDictionary.DictionaryOptions(attributes),
                new FormatOptions(version,
                        0 != (optionsFlags & FormatSpec.CONTAINS_TIMESTAMP_FLAG)));
                new FormatOptions(version, FileHeader.ATTRIBUTE_VALUE_TRUE.equals(
                        attributes.get(FileHeader.HAS_HISTORICAL_INFO_ATTRIBUTE))));
        return header;
    }

+0 −1
Original line number Diff line number Diff line
@@ -499,7 +499,6 @@ public final class BinaryDictDecoderUtils {
        final int nodeArrayOriginPos = dictDecoder.getPosition();

        do { // Scan the linked-list node.
            final int nodeArrayHeadPos = dictDecoder.getPosition();
            final int count = dictDecoder.readPtNodeCount();
            int groupPos = dictDecoder.getPosition();
            for (int i = count; i > 0; --i) { // Scan the array of PtNode.
+2 −9
Original line number Diff line number Diff line
@@ -755,14 +755,6 @@ public class BinaryDictEncoderUtils {
        return discretizedFrequency > 0 ? discretizedFrequency : 0;
    }

    /**
     * Makes the 2-byte value for options flags. Unused at the moment, and always 0.
     */
    private static final int makeOptionsValue(final FormatOptions formatOptions) {
        // TODO: why doesn't this handle CONTAINS_TIMESTAMP_FLAG?
        return 0;
    }

    /**
     * Makes the flag value for a shortcut.
     *
@@ -949,7 +941,8 @@ public class BinaryDictEncoderUtils {
        headerBuffer.write((byte) (0xFF & version));

        // Options flags
        final int options = makeOptionsValue(formatOptions);
        // TODO: Remove this field.
        final int options = 0;
        headerBuffer.write((byte) (0xFF & (options >> 8)));
        headerBuffer.write((byte) (0xFF & options));
        final int headerSizeOffset = headerBuffer.size();
+4 −8
Original line number Diff line number Diff line
@@ -192,10 +192,6 @@ public final class FormatSpec {
    static final int MINIMUM_SUPPORTED_VERSION = VERSION2;
    static final int MAXIMUM_SUPPORTED_VERSION = VERSION4;

    // These options need to be the same numeric values as the one in the native reading code.
    // TODO: Make the native reading code read this variable.
    static final int CONTAINS_TIMESTAMP_FLAG = 0x10;

    // TODO: Make this value adaptative to content data, store it in the header, and
    // use it in the reading code.
    static final int MAX_WORD_LENGTH = Constants.DICTIONARY_MAX_WORD_LENGTH;
@@ -249,26 +245,26 @@ public final class FormatSpec {
    static final String TRIE_FILE_EXTENSION = ".trie";
    public static final String HEADER_FILE_EXTENSION = ".header";
    static final String FREQ_FILE_EXTENSION = ".freq";
    static final String UNIGRAM_TIMESTAMP_FILE_EXTENSION = ".timestamp";
    // tat = Terminal Address Table
    static final String TERMINAL_ADDRESS_TABLE_FILE_EXTENSION = ".tat";
    static final String BIGRAM_FILE_EXTENSION = ".bigram";
    static final String SHORTCUT_FILE_EXTENSION = ".shortcut";
    static final String LOOKUP_TABLE_FILE_SUFFIX = "_lookup";
    static final String CONTENT_TABLE_FILE_SUFFIX = "_index";
    static final int FLAGS_IN_FREQ_FILE_SIZE = 1;
    static final int FREQUENCY_AND_FLAGS_SIZE = 2;
    static final int TERMINAL_ADDRESS_TABLE_ADDRESS_SIZE = 3;
    static final int UNIGRAM_TIMESTAMP_SIZE = 4;
    static final int UNIGRAM_COUNTER_SIZE = 1;
    static final int UNIGRAM_LEVEL_SIZE = 1;

    // With the English main dictionary as of October 2013, the size of bigram address table is
    // is 345KB with the block size being 16.
    // This is 54% of that of full address table.
    static final int BIGRAM_ADDRESS_TABLE_BLOCK_SIZE = 16;
    static final int BIGRAM_CONTENT_COUNT = 2;
    static final int BIGRAM_CONTENT_COUNT = 1;
    static final int BIGRAM_FREQ_CONTENT_INDEX = 0;
    static final int BIGRAM_TIMESTAMP_CONTENT_INDEX = 1;
    static final String BIGRAM_FREQ_CONTENT_ID = "_freq";
    static final String BIGRAM_TIMESTAMP_CONTENT_ID = "_timestamp";
    static final int BIGRAM_TIMESTAMP_SIZE = 4;
    static final int BIGRAM_COUNTER_SIZE = 1;
    static final int BIGRAM_LEVEL_SIZE = 1;
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public final class FusionDictionary implements Iterable<Word> {
            mData = new ArrayList<PtNode>();
        }
        public PtNodeArray(ArrayList<PtNode> data) {
            Collections.sort(data, PTNODE_COMPARATOR);
            mData = data;
        }
    }
Loading