Struct DepGraphMut

Source
pub struct DepGraphMut<'a> { /* private fields */ }
Expand description

A mutable graph view.

This data structure provides a mutable view of a CoNLL-U dependency graph. The view can be used to retrieve the dependents of a head or the head of a dependent. In addition, the add_deprel method can be used to add dependency relations to the graph.

Implementations§

Source§

impl<'a> DepGraphMut<'a>

Source

pub fn add_deprel<S>(&mut self, triple: DepTriple<S>) -> Result<(), Error>
where S: Into<String>,

Add a dependency relation between head and dependent.

If dependent already has a head relation, this relation is removed to ensure single-headedness.

Source

pub fn dependents(&self, head: usize) -> impl Iterator<Item = DepTriple<&str>>

Return an iterator over the dependents of head.

Source

pub fn head(&self, dependent: usize) -> Option<DepTriple<&str>>

Return the head relation of dependent, if any.

Source

pub fn remove_head_rel(&mut self, dependent: usize) -> Option<DepTriple<String>>

Remove relation of a token to its head.

Returns the index of the head iff a head was removed.

Source

pub fn len(&self) -> usize

Get the number of nodes in the dependency graph.

This is equal to the number of tokens, plus one root node.

Trait Implementations§

Source§

impl<'a> Index<usize> for DepGraphMut<'a>

Source§

type Output = Node

The returned type after indexing.
Source§

fn index(&self, idx: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<usize> for DepGraphMut<'a>

Source§

fn index_mut(&mut self, idx: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DepGraphMut<'a>

§

impl<'a> RefUnwindSafe for DepGraphMut<'a>

§

impl<'a> Send for DepGraphMut<'a>

§

impl<'a> Sync for DepGraphMut<'a>

§

impl<'a> Unpin for DepGraphMut<'a>

§

impl<'a> !UnwindSafe for DepGraphMut<'a>

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.