Unittests Testing the hashing
document[] corp = [["asdahsk", "sdlfjsldj","çsldkfçk"],["sdjçlkj","sadjfl"],["sdfçls","oirgk", "sdkfj"]]; HashCorpus H = new HashCorpus(corp, "test_corpus"); assert("asdahsk" in H.encode_dictionary);
Test the loading of dictionaries
document[] corp = [ ["asdahsk", "sdlfjsldj", "çsldkfçk"], ["sdjçlkj", "sadjfl"], ["sdfçls", "oirgk", "sdkfj"] ]; HashCorpus H = new HashCorpus(corp, "test_corpus"); // Make a copy of the dictionaries dictionary original_enc_dict = H.encode_dictionary; Ddictionary original_dec_dict = H.decode_dictionary; // Force the re-loading from disk again; H._load_dictionaries(); foreach (word; [ "asdahsk", "sdlfjsldj", "çsldkfçk", "sdjçlkj", "sadjfl", "sdfçls", "oirgk", "sdkfj" ]) { assert(original_enc_dict[word] == H.encode_dictionary[word]); } assert(isAssociativeArray!(typeof(H.decode_dictionary))); foreach (key, val; H.decode_dictionary) { assert(isSomeString!(typeof(key))); assert(isArray!(typeof(val))); assert(key in original_dec_dict); }
Python wrapper