[][src]Trait lumberjack::io::Decode

pub trait Decode: Sized {
    fn decode(encoding: AbsoluteEncoding, terminals: Vec<Terminal>) -> Self;
fn remove_dummy_nodes(&mut self) -> Result<(), Error>; }

Decode trait.

Defines methods how to construct trees from encodings.

Required methods

fn decode(encoding: AbsoluteEncoding, terminals: Vec<Terminal>) -> Self

Construct a tree from an absolute scale encoding.

Decoding from a RelativeEncoding requires conversion into an AbsoluteEncoding:

use lumberjack::Tree;
use lumberjack::io::{AbsoluteEncoding, Encode, Decode, PTBFormat};

let tree = PTBFormat::Simple.string_to_tree("(Some (Test tree))").unwrap();
let terminals = tree.terminals().map(|t| tree[t].terminal().unwrap().clone()).collect::<Vec<_>>();
let relative_encoding = tree.encode_relative().unwrap();
let absolute = AbsoluteEncoding::try_from_relative(relative_encoding).unwrap_or_fix();
let tree = Tree::decode(absolute, terminals);

fn remove_dummy_nodes(&mut self) -> Result<(), Error>

Loading content...

Implementors

impl Decode for Tree[src]

Loading content...