[][src]Struct conllx::graph::Sentence

pub struct 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 PartialEq<Sentence> for Sentence[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl Default for Sentence[src]

impl Clone for Sentence[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<Sentence> for DiGraph<Node, Edge>[src]

impl<'a> From<&'a Sentence> for &'a DiGraph<Node, Edge>[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?

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?

impl Eq for Sentence[src]

impl Display for Sentence[src]

impl Debug for Sentence[src]

impl Index<usize> for Sentence[src]

type Output = Node

The returned type after indexing.

impl IndexMut<usize> for Sentence[src]

impl FromIterator<Token> for Sentence[src]

Auto Trait Implementations

impl Send for Sentence

impl Sync for Sentence

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]