Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just read your new posts and re-read the original post, and I think I just fully understood the goal here. Sorry it took so long, I'm kind of slow.</p> <p>To paraphrase the question, on line 4 of the original example:</p> <pre><code>{ "(AN", "ANCIENT", {1, 2, 2}, {1, 2, 3}, "U+4E94)", "FIVE"}, </code></pre> <p>You'd want to translate the triples into references to strings used earlier, in an attempt to compress the data. That line becomes:</p> <pre><code>{ "(AN", "ANCIENT", "FORM", "OF", "U+4E94)", "FIVE"}, </code></pre> <p>If the goal is compression I don't think you'll see much gain here. The self-referencing triples are each 3 bytes, but the strings that are being substituted out are only 8 bytes total, counting null terminators, and you only save 2 bytes on this line. And that's for using chars. Since your structure is so big that you're going to need to use ints for references, your triple is actually 12 bytes, which is even worse. In this case you'll only ever save space by substituting for words that are 12 ascii characters or more.</p> <p>If I'm totally off base here then feel free to ignore me, but I think the approach of tokenizing on spaces and then removing duplicate words is just kind of a poor man's <a href="http://en.wikipedia.org/wiki/Huffman_coding" rel="nofollow noreferrer">Huffman compression</a>. Huffman where the alphabet is a list of <a href="http://en.wikipedia.org/wiki/Longest_common_substring_problem" rel="nofollow noreferrer">longest common substrings</a>, or some other standard text compression method would probably work well for this problem.</p> <p>If for some reason this isn't an option though, I think I would get a list of all unique words in your data and use that as a lookup table. Then store all strings as a list of indexes into that table. You'd have to use two tables, but in the end it might be simpler, and it would save you the space being used by the leading 1's you're using as the "abbrev marker" now. Basically, your abbreviation markers would become a single index instead of a triplet.</p> <p>So,</p> <pre><code>const char * words[] = { "hello", "world", "goodbye", "cruel" }; const int strings[] = { { 0, 1 }, { 2, 3, 1 } }; </code></pre> <p>You'd still lose a lot of space if your strings aren't of roughly uniform length though.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload