thesaurus_wordnet/lib.rs
1//! This crate is fairly low level, I reccomend you use the higher-level [`thesaurus`](https://crates.io/crates/thesaurus) crate.
2
3use libflate::gzip::Decoder;
4use std::io::Read;
5
6const WORDNET_DICT_COMPRESSED: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/wordnet.gz"));
7
8/// Uncompress the dictionary from memory.
9pub fn uncompress() -> String {
10 let mut dec = Decoder::new(WORDNET_DICT_COMPRESSED)
11 .expect("Failed to initialize runtime dictionary decoder");
12 let mut output = Vec::new();
13 dec.read_to_end(&mut output)
14 .expect("Failed to decompress dictionary");
15
16 String::from_utf8(output).unwrap()
17}