pub struct String2Tree { /* private fields */ }Expand description
A String2Tree struct, mainly holds the tree object. This type will implement the String2StructureBuilder, with a constituency String as Input and a made Tree-String- as output.
Trait Implementations§
Source§impl String2StructureBuilder for String2Tree
impl String2StructureBuilder for String2Tree
Source§fn new() -> Self
fn new() -> Self
Initialization of a String2Tree object
§Examples
use parsed_to_plot::String2Tree;
use parsed_to_plot::String2StructureBuilder;
let _string2tree: String2Tree = String2StructureBuilder::new();Source§fn get_structure(&self) -> Self::Out
fn get_structure(&self) -> Self::Out
Get a copy of a tree (should be called after build)
Source§fn build(&mut self, input: &mut Self::Input) -> Result<(), Box<dyn Error>>
fn build(&mut self, input: &mut Self::Input) -> Result<(), Box<dyn Error>>
A recursive method that builds a mutable Tree-String- structure from a constituency string Returns Ok if the process was succesful (error otherwise)
§Examples
use parsed_to_plot::String2Tree;
use parsed_to_plot::String2StructureBuilder;
let mut constituency = String::from("(S (NP (det The) (N people)) (VP (V watch) (NP (det the) (N game))))");
let gold_root_data = "S";
let mut string2tree: String2Tree = String2StructureBuilder::new();
if let Err(e) = string2tree.build(&mut constituency) {
panic!("{}", e);
}
let mut tree = string2tree.get_structure();
let prediction_root_data = tree.get(tree.root_node_id().unwrap()).unwrap().data();
assert_eq!(prediction_root_data, gold_root_data);type Input = String
type Out = Tree<String>
Auto Trait Implementations§
impl Freeze for String2Tree
impl RefUnwindSafe for String2Tree
impl Send for String2Tree
impl Sync for String2Tree
impl Unpin for String2Tree
impl UnwindSafe for String2Tree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more