pub struct CharwiseDoubleArrayAhoCorasickBuilder { /* private fields */ }
Expand description

Implementations

Creates a new CharwiseDoubleArrayAhoCorasickBuilder.

Examples
use daachorse::CharwiseDoubleArrayAhoCorasickBuilder;

let patterns = vec!["全世界", "世界", "に"];

let builder = CharwiseDoubleArrayAhoCorasickBuilder::new();
let pma = builder.build(patterns).unwrap();

let mut it = pma.find_iter("全世界中に");

let m = it.next().unwrap();
assert_eq!((0, 9, 0), (m.start(), m.end(), m.value()));

let m = it.next().unwrap();
assert_eq!((12, 15, 2), (m.start(), m.end(), m.value()));

assert_eq!(None, it.next());

Specifies MatchKind to build.

Arguments
  • kind - Match kind.

Specifies the number of last blocks to search bases.

The smaller the number is, the faster the construction time will be; however, the memory efficiency can be degraded.

Arguments
  • n - The number of last blocks.
Panics

n must be greater than or equal to 1.

Builds and returns a new CharwiseDoubleArrayAhoCorasick from input patterns. The value i is automatically associated with patterns[i].

Arguments
  • patterns - List of patterns.
Errors

DaachorseError is returned when

  • patterns is empty,
  • patterns contains entries of length zero,
  • patterns contains duplicate entries,
  • the conversion from the index i to the specified type V fails,
  • the scale of patterns exceeds the expected one, or
  • the scale of the resulting automaton exceeds the expected one.
Examples
use daachorse::CharwiseDoubleArrayAhoCorasickBuilder;

let patterns = vec!["全世界", "世界", "に"];
let pma = CharwiseDoubleArrayAhoCorasickBuilder::new()
    .build(patterns)
    .unwrap();

let mut it = pma.find_iter("全世界中に");

let m = it.next().unwrap();
assert_eq!((0, 9, 0), (m.start(), m.end(), m.value()));

let m = it.next().unwrap();
assert_eq!((12, 15, 2), (m.start(), m.end(), m.value()));

assert_eq!(None, it.next());

Builds and returns a new CharwiseDoubleArrayAhoCorasick from input pattern-value pairs.

Arguments
  • patvals - List of pattern-value pairs.
Errors

DaachorseError is returned when

  • patvals is empty,
  • patvals contains patterns of length zero,
  • patvals contains duplicate patterns,
  • the scale of patvals exceeds the expected one, or
  • the scale of the resulting automaton exceeds the expected one.
Examples
use daachorse::CharwiseDoubleArrayAhoCorasickBuilder;

let patvals = vec![("全世界", 0), ("世界", 10), ("に", 100)];
let pma = CharwiseDoubleArrayAhoCorasickBuilder::new()
    .build_with_values(patvals)
    .unwrap();

let mut it = pma.find_iter("全世界中に");

let m = it.next().unwrap();
assert_eq!((0, 9, 0), (m.start(), m.end(), m.value()));

let m = it.next().unwrap();
assert_eq!((12, 15, 100), (m.start(), m.end(), m.value()));

assert_eq!(None, it.next());

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.