[][src]Struct parattice::lattice_kmp::LatticeKMP

pub struct LatticeKMP<'a> { /* fields omitted */ }

Implementations

impl<'a> LatticeKMP<'a>[src]

pub fn new(pattern: Vec<&'a str>) -> LatticeKMP<'a>[src]

Returns LatticeKMP with the given pattern.

Arguments

  • pattern - A word array

Example

use parattice::LatticeKMP;

let pattern = vec!["幹", "細胞"];
let kmp = LatticeKMP::new(pattern);

pub fn search(&self, lattice: &'a Lattice) -> Vec<Vec<(&'a str, usize)>>[src]

Returns paths of found patterns.

Arguments

  • lattice - A lattice

Example

use parattice::PaRattice;
use parattice::Lattice;
use parattice::LatticeKMP;

let pattern = vec!["幹", "細胞"];
let kmp = LatticeKMP::new(pattern);

let paradict = vec![
    vec![
        vec!["blood", "stem", "cell"],
        vec!["造血", "幹", "細胞"],
        vec!["hematopoietic", "stem", "cell"],
    ],
    vec![
        vec!["造血", "幹", "細胞", "移植"],
        vec!["hematopoietic", "stem", "cell", "transplantation"],
    ],
    vec![vec!["stem", "cell"], vec!["幹", "細胞"]],
    vec![
        vec!["幹", "細胞", "移植"],
        vec!["rescue", "transplant"],
        vec!["stem", "cell", "rescue"],
    ],
    vec![vec!["rescue"], vec!["救命"]],
    vec![vec!["blood"], vec!["血液"]],
];
let parattice = PaRattice::new(paradict);
let words = vec!["造血", "幹", "細胞", "移植"];
let lattice = parattice.get_lattice(&words, true, 2);

let results = kmp.search(&lattice);

Auto Trait Implementations

impl<'a> RefUnwindSafe for LatticeKMP<'a>

impl<'a> Send for LatticeKMP<'a>

impl<'a> Sync for LatticeKMP<'a>

impl<'a> Unpin for LatticeKMP<'a>

impl<'a> UnwindSafe for LatticeKMP<'a>

Blanket Implementations

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

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

impl<T> BorrowMut<T> for T where
    T: ?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.