Beispiel #1
0
        public CompressResultContainer Compress(string sourceString)
        {
            var result = new CompressResultContainer();

            try
            {
                archiveCommonDictionary.Initialize(sourceString);

                var isCreated = InitializeDictionary(sourceString);
                if (isCreated)
                {
                    compressor         = new Compressor(archiveDictionary);
                    result.EncodeBytes = compressor.Compress(sourceString);
                }
                else
                {
                    throw new Exception("Dictonary was not create.");
                }

                result.Dictionary       = DictonaryToJSON(archiveDictionary);
                result.CommonDictionary = DictonaryToJSON(archiveCommonDictionary);

                result.DictionaryWordCount       = archiveDictionary.Dictonary.Count;
                result.CommonDictionaryWordCount = archiveCommonDictionary.Dictonary.Count;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }

            return(result);
        }
Beispiel #2
0
 public bool InitializeDictionary(string sourceString)
 {
     return(archiveDictionary.Initialize(sourceString));
 }