use sigil::{word_particle, Particle, Sentence};
pub type Edge = (Particle, Particle);
pub fn expand(s: &Sentence) -> Vec<Edge> {
let subject = word_particle(&s.subject);
let object = word_particle(&s.object);
let relation = word_particle(&s.relation);
let axon = bbg::state::axon_id(&subject, &object);
vec![(subject, object), (axon, relation)]
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn expands_to_base_and_axon_type() {
let s = sigil::parse("cat is-a animal").unwrap();
let edges = expand(&s);
assert_eq!(edges.len(), 2, "base link + axon-type link");
assert_eq!(edges[0], (word_particle("cat"), word_particle("animal")));
let axon = bbg::state::axon_id(&word_particle("cat"), &word_particle("animal"));
assert_eq!(edges[1], (axon, word_particle("is-a")));
}
}