Package org.toubassi.femtozip.dictionary

Examples of org.toubassi.femtozip.dictionary.DictionaryOptimizer.optimize()


    protected void buildDictionary() throws IOException {
        File dir = new File(path);
        List<String> files = Arrays.asList(dir.list());
        DocumentList documents = new FileDocumentList(path, files);
        DictionaryOptimizer optimizer = new DictionaryOptimizer(documents);
        byte[] dictionary = optimizer.optimize(maxDictionarySize  > 0 ? maxDictionarySize : 64*1024);
       
        FileOutputStream fileOut = new FileOutputStream(modelPath);
        fileOut.write(dictionary);
        fileOut.close();
    }
View Full Code Here


    @Test
    public void testSubstrings() throws IOException {
       
       
        DictionaryOptimizer optimizer = new DictionaryOptimizer(new ArrayDocumentList("a man a plan a canal panama"));
        optimizer.optimize(64*1024);
       
        Assert.assertEquals(2, optimizer.getSubstringCount());
        Assert.assertEquals(25, optimizer.getSubstringScore(0));
        Assert.assertEquals("n a ", new String(optimizer.getSubstringBytes(0), "UTF-8"));
        Assert.assertEquals(40, optimizer.getSubstringScore(1));
View Full Code Here

    @Test
    public void testDictPack() throws IOException {
       
       
        DictionaryOptimizer optimizer = new DictionaryOptimizer(new ArrayDocumentList("11111", "11111", "00000"));
        byte[] dictionary = optimizer.optimize(64*1024);

        int i = 0, count;
        for (i = 0, count = dictionary.length; i < count && dictionary[i] == 0; i++) {
        }
        String d = new String(Arrays.copyOfRange(dictionary, i, dictionary.length));
View Full Code Here

        }
    }
   
    protected static byte[] buildDictionary(DocumentList documents) throws IOException {
        DictionaryOptimizer optimizer = new DictionaryOptimizer(documents);
        return optimizer.optimize(64*1024);
    }
   
    protected SubstringPacker.Consumer createModelBuilder() {
        return null;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.