[−][src]Struct conllx::graph::Sentence
A CoNLL-X dependency graph.
Sentence
stores a dependency graph. The nodes in the graph
(except the special root node) are tokens that have the fields
of the CoNLL-X format. Dependency relations are stored as edges
in the graph.
This data structure is a thin wrapper around the petgraph
DiGraph
data structure that enforces variants such as
single-headedness. The into_inner
/get_ref
methods can
be used to unwrap or get a reference to the wrapped graph.
Methods
impl Sentence
[src]
pub fn new() -> Self
[src]
Construct a new sentence.
The sentence will be constructed such that the first token is the root of the dependency graph:
extern crate conllx; use conllx::graph::{Node, Sentence}; let sentence = Sentence::new(); assert_eq!(sentence[0], Node::Root);
pub fn get_ref(&self) -> &DiGraph<Node, Edge>
[src]
Get a reference to the DiGraph
of the sentence.
pub fn into_inner(self) -> DiGraph<Node, Edge>
[src]
Unwrap the DiGraph
of the sentence.
ⓘImportant traits for Iter<'a>pub fn iter(&self) -> Iter
[src]
Get an iterator over the nodes in the graph.
ⓘImportant traits for IterMut<'a>pub fn iter_mut(&mut self) -> IterMut
[src]
Get a mutable iterator over the nodes in the graph.
pub fn push(&mut self, token: Token) -> usize
[src]
Add a new token to the graph.
Tokens should always be pushed in sentence order.
Returns the index of the token. The first pushed token has index 1, since index 0 is reserved by the root of the graph.
pub fn dep_graph(&self) -> DepGraph
[src]
Get the non-projective dependency graph.
pub fn dep_graph_mut(&mut self) -> DepGraphMut
[src]
Get the non-projective graph mutably.
pub fn proj_dep_graph(&self) -> DepGraph
[src]
Get the projective graph.
pub fn proj_dep_graph_mut(&mut self) -> DepGraphMut
[src]
Get the projective graph mutably.
pub fn len(&self) -> usize
[src]
Get the number of nodes in the dependency graph.
This is equal to the number of tokens, plus one root node.
Trait Implementations
impl Eq for Sentence
[src]
impl Default for Sentence
[src]
impl Clone for Sentence
[src]
impl PartialEq<Sentence> for Sentence
[src]
impl<'a> IntoIterator for &'a Sentence
[src]
type Item = &'a Node
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> IntoIterator for &'a mut Sentence
[src]
type Item = &'a mut Node
The type of the elements being iterated over.
type IntoIter = IterMut<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl From<Sentence> for DiGraph<Node, Edge>
[src]
impl<'a> From<&'a Sentence> for &'a DiGraph<Node, Edge>
[src]
impl Index<usize> for Sentence
[src]
type Output = Node
The returned type after indexing.
fn index(&self, idx: usize) -> &Self::Output
[src]
impl IndexMut<usize> for Sentence
[src]
impl Debug for Sentence
[src]
impl Display for Sentence
[src]
impl FromIterator<Token> for Sentence
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = Token>,
[src]
T: IntoIterator<Item = Token>,
Auto Trait Implementations
impl Sync for Sentence
impl Send for Sentence
impl Unpin for Sentence
impl UnwindSafe for Sentence
impl RefUnwindSafe for Sentence
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,