wordcloud/
lib.rs

1/*!
2   WordCloud: A simplified way to create Wordclouds in Rust.
3
4   ### Simple Example
5
6   ```
7   use wordcloud::*;
8   use wordcloud::font::*;
9
10   let mut font_data = Vec::from(include_bytes!("font.ttf") as &[u8]);
11   let font_set = FontSetBuilder::new()
12       .push(Font::from_data(&mut font_data).unwrap())
13       .build();
14
15   let output_dimensions = Dimensions::from_wh(1000, 1000);
16   let wc = WordCloudBuilder::new()
17       .dimensions(output_dimensions)
18       .font(&font_set)
19       .build()
20       .unwrap();
21
22   let input_text = io::read_string_from_file("input_text.txt").unwrap();
23   let ranked = RankedWords::rank(input_text.split_whitespace().collect());
24
25   wc.write_content(ranked, 2000);
26   wc.export_rendered_to_file("output.svg").unwrap();
27   ```
28
29   ## Using Stopwords
30
31   ```
32   use wordcloud::*;
33   use wordcloud::font::*;
34
35   // Create the default StopWords set using the "stopwords" crate feature
36   let stop_words = StopWords::default();
37
38   let input_text = io::read_string_from_file("input_text.txt").unwrap();
39   let ranked = RankedWords::rank(
40       input_text
41           .split_whitespace()
42           // filter out the StopWords using the iterator function
43           // a similar named function also exists for rayon's ParallelIterators
44           .filter_stop_words(&stop_words)
45           // filter out everything that is just a number
46           .filter(
47               |x| x.parse::<f64>().is_err()
48           )
49           .collect()
50   );
51
52   // ...
53   ```
54
55   ## Using Background Images
56
57   ```
58   use wordcloud::*;
59
60   // ...
61
62   let image = image::load_from_memory(test_image).expect("image load failed");
63   let wc = WordCloudBuilder::new()
64       .dimensions(output_dimensions)
65       .font(&font_set)
66       .image(&image)
67       .build()
68       .unwrap();
69
70   // ...
71   ```
72
73   Example results can be found on the GitHub page.
74*/
75
76mod cloud;
77mod common;
78mod filtering;
79mod image;
80
81/**
82    Provides helpers for IO-Operations
83*/
84pub mod io;
85mod rank;
86
87pub use cloud::*;
88pub use filtering::*;
89
90pub use common::font;
91
92pub use crate::image::Dimensions;
93pub use rank::RankedWords;
94
95mod types;