Struct PointerRef

Source
pub struct PointerRef<'db> {
    pub relationship: Relationship,
    pub part_of_speech: PartOfSpeech,
    /* private fields */
}
Expand description

Connects a Sense to words that relationship

A PointerRef has not been loaded from the database yet. You can call read() to do that.

Fields§

§relationship: Relationship

The relationship this pointer has from the original word to to the sense you can read with read()

§part_of_speech: PartOfSpeech

The part of the speech that this new sense has.

Implementations§

Source§

impl<'db> PointerRef<'db>

Source

pub fn read(&self) -> Sense<'db>

Read this pointer from the database files. This might lead to a Sense that you already have seen so be careful to not recurse indefinitely.

If you only use look at once relationship, then everything should be ok

Examples found in repository?
examples/horse_isa.rs (line 11)
3
4
5
6
7
8
9
10
11
12
13
fn main()
{
	let wn = wordnet::Database::open(&::std::path::Path::new("/usr/share/wordnet")).unwrap();

	let senses = wn.senses("horse");
	senses[0]
		.pointers.iter()
		.filter(|p| p.relationship == wordnet::Relationship::Hypernym)
		.map(|p| p.read())
		.for_each( |e| println!("a horse is an {}", e.synonyms[0].word));
}
More examples
Hide additional examples
examples/senses.rs (line 16)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn print_tree(indent : u32, ptr : &wordnet::PointerRef)
{
  if ptr.relationship != wordnet::Relationship::Hypernym
    { return; }

  let sense = ptr.read();
  print_indent(indent);
  println!(
    " => {}",
    sense.synonyms.iter().fold(
      "".to_string(),
      |acc,ref x|
      {
        let s = if acc.len()==0 { "" } else { ", " };
        format!("{}{}{}", acc, s, x.word)
      }
    ),
  );
  for p in &sense.pointers
  {
    print_tree(indent+1, p);
  }

}

Trait Implementations§

Source§

impl<'db> Debug for PointerRef<'db>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'db> Freeze for PointerRef<'db>

§

impl<'db> RefUnwindSafe for PointerRef<'db>

§

impl<'db> Send for PointerRef<'db>

§

impl<'db> Sync for PointerRef<'db>

§

impl<'db> Unpin for PointerRef<'db>

§

impl<'db> UnwindSafe for PointerRef<'db>

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.