Activating Latent Semantic Models with Natural Language Inference
andrew-lucker
7,552 views
Next Steps
To implement the base four emotional states (happiness, sadness, anger, and fear) we must first create a data structure capable of encoding the variable identifier and confidence. To keep things simple we will simply create a list containing a tuple of (identifer, confidence). This now allows us to encode mixed emotions as seen below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn read_emotion() -> Vec<(String,f64)> { vec![
("sad".to_string(),0.75),
("angry".to_string(),0.33),
("happy".to_string(),-0.95)
]}
fn draw_emotion(emotions: Vec<(String,f64)>) {
for ref ec in &emotions {
let ref emotion = ec.0;
let confidence = ec.1;
if confidence > 0.0 { println!("{}: {}", emotion, confidence) }
else { println!("not {}: {}", emotion, confidence) }
}
}
fn main() {
draw_emotion( read_emotion() );
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.