pub enum PTBTree {
InnerNode {
label: String,
children: Vec<PTBTree>,
},
TerminalNode {
label: String,
},
}Expand description
Arbitrarily wide recursive trees of String.
Variants§
Implementations§
Source§impl PTBTree
impl PTBTree
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Return bracketed (and outside-bracketed!) PTB notation:
use ptb_reader::PTBTree;
let tree = PTBTree::InnerNode{ label: "NT".to_string(), children: vec![PTBTree::TerminalNode{ label: "t".to_string() }] };
assert_eq!(tree.render(), "((NT t))")Sourcepub fn front(&self) -> String
pub fn front(&self) -> String
Return String from joined terminals at the leaves (i.e, front, yield).
use ptb_reader::PTBTree;
let tree = PTBTree::InnerNode{ label: "NT".to_string(), children: vec![PTBTree::TerminalNode{ label: "t".to_string() }] };
assert_eq!(tree.front(), "t")Sourcepub fn pos_front(&self) -> String
pub fn pos_front(&self) -> String
Return String from joined pre-terminals (i.e., POS tags).
use ptb_reader::PTBTree;
let tree = PTBTree::InnerNode{ label: "NT".to_string(), children: vec![PTBTree::TerminalNode{ label: "t".to_string() }] };
assert_eq!(tree.pos_front(), "NT")Sourcepub fn front_length(&self) -> usize
pub fn front_length(&self) -> usize
Return number of terminal words, i.e. length of front.
Sourcepub fn strip_all_predicate_annotations(&mut self)
pub fn strip_all_predicate_annotations(&mut self)
Remove predicate-argument annotations and trace elements. See <http://dx.doi.org/10.3115/1075812.1075835 The Penn Treebank: annotating predicate argument structure>. Thanks to Toni Dietze for formalizing the necessary stripping :)
Trait Implementations§
impl Eq for PTBTree
impl StructuralPartialEq for PTBTree
Auto Trait Implementations§
impl Freeze for PTBTree
impl RefUnwindSafe for PTBTree
impl Send for PTBTree
impl Sync for PTBTree
impl Unpin for PTBTree
impl UnwindSafe for PTBTree
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