rnltk/
sample_data.rs

1//! Module containing functions to retrieve sample data for
2//! use in the main modules.
3
4use crate::sentiment::CustomWords;
5use crate::document::GenericMatrix;
6use nalgebra::DMatrix;
7
8
9pub fn get_sample_custom_word_dict() -> CustomWords {
10    let custom_word_dict = r#"
11    {
12        "abduction": {
13            "word": "abduction",
14            "stem": "abduct",
15            "avg": [2.76, 5.53],
16            "std": [2.06, 2.43]
17        },
18        "betrayed": {
19            "word": "betrayed",
20            "stem": "betrai",
21            "avg": [2.57, 7.24],
22            "std": [1.83, 2.06]
23        },
24        "bees": {
25            "word": "bees",
26            "stem": "bee",
27            "avg": [3.2, 6.51],
28            "std": [2.07, 2.14]
29        }
30    }"#;
31
32    serde_json::from_str(custom_word_dict).unwrap()
33}
34
35pub fn get_term_frequencies() -> GenericMatrix {
36    DMatrix::from_row_slice(11, 4, &[1., 0., 0., 0.,
37        0., 1., 0., 0.,
38        0., 0., 1., 1.,
39        1., 0., 0., 0.,
40        1., 0., 0., 0.,
41        2., 0., 0., 0.,
42        0., 0., 0., 1.,
43        0., 1., 0., 0.,
44        0., 0., 0., 1.,
45        0., 0., 1., 0.,
46        1., 0., 0., 0.,])
47}