pub fn parse(&mut self, sen: Sentence) -> Result<(), MarkovError> {
    let Sentence(ref raw) = sen;

    // Be sure there's enough elements.
    if raw.len() < 3 {
      return Err(MarkovError::InsufficientLength)
    }
    
    // This sucks but I'm not sure there's a nicer way to do it.
    for ind in 1 .. (raw.len() - 1) {
      let prefix = (raw[ind - 1].clone(), raw[ind].clone());
      let next = raw[ind + 1].clone();

      if !self.0.contains_key(&prefix) {
        self.0.insert(prefix, vec![next]);
      }

      else {
        let mut existing = self.0.get_mut(&prefix).unwrap();
        existing.push(next);
      }
    }

    Ok(())
  }
/// Take a Sentence and add it to the dictionary for text generation.
Take a Sentence and add it to the dictionary for text generation.
Take a Sentence and add it to the dictionary for text generation .
pub fn parse(&mut self, sen: Sentence) -> Result<(), MarkovError> {
    let Sentence(ref raw) = sen;
    // Be sure there's enough elements.
    if raw.len() < 3 {
      return Err(MarkovError::InsufficientLength)
    }
    // This sucks but I'm not sure there's a nicer way to do it.
    for ind in 1 .. (raw.len() - 1) {
      let prefix = (raw[ind - 1].clone(), raw[ind].clone());
      let next = raw[ind + 1].clone();
      if !self.0.contains_key(&prefix) {
        self.0.insert(prefix, vec![next]);
      }
      else {
        let mut existing = self.0.get_mut(&prefix).unwrap();
        existing.push(next);
      }
    }
    Ok(())
  }
pub fn parse ( & mut self , sen : Sentence ) -> Result < ( ) , MarkovError > { let Sentence ( ref raw ) = sen ; // Be sure there's enough elements. if raw . len ( ) < 3 { return Err ( MarkovError :: InsufficientLength ) } // This sucks but I'm not sure there's a nicer way to do it. for ind in 1 .. ( raw . len ( ) - 1 ) { let prefix = ( raw [ ind - 1 ] . clone ( ) , raw [ ind ] . clone ( ) ) ; let next = raw [ ind + 1 ] . clone ( ) ; if ! self . 0 . contains_key ( & prefix ) { self . 0 . insert ( prefix , vec ! [ next ] ) ; } else { let mut existing = self . 0 . get_mut ( & prefix ) . unwrap ( ) ; existing . push ( next ) ; } } Ok ( ( ) ) }
Take a Sentence and add it to the dictionary for text generation.
Take a Sentence and add it to the dictionary for text generation .
&mut self
sen
Sentence