String2Tree

Struct String2Tree 

Source
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

Source§

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

Get a copy of a tree (should be called after build)

Source§

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);
Source§

type Input = String

Source§

type Out = Tree<String>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.