Skip to main content

parse

Function parse 

Source
pub fn parse(
    text: &str,
    locale: &Locale,
    dims: &[DimensionKind],
    context: &Context,
    options: &Options,
) -> Vec<Entity>
Expand description

Parse natural language text and return structured entities.

§Arguments

  • text - The input text to parse
  • locale - The locale (language + optional region)
  • dims - Which dimensions to extract (empty = all)
  • context - Reference time and locale context
  • options - Parsing options (e.g., whether to include latent matches)

§Example

use duckling::{parse, Locale, Lang, Context, Options, DimensionKind};

let context = Context::default();
let options = Options::default();
let locale = Locale::new(Lang::EN, None);

let entities = parse("I need 3 degrees celsius", &locale, &[DimensionKind::Temperature], &context, &options);
assert!(!entities.is_empty());