Expand description
§nl3
Natural language triples — parse short plain-English Subject–Predicate–Object phrases into validated triples.
You supply a grammar (the valid S-P-O relations) and a vocabulary
(word-stem → predicate mappings), then Nl3::parse turns phrases into
Triples, validating them and flipping reversed phrasings.
use nl3::Nl3;
let nl3 = Nl3::builder()
.grammar(["users message users"])
.vocabulary([("contact", "message"), ("msg", "message")])
.build();
let triple = nl3.parse("user jack contacts user jill").unwrap();
assert_eq!(triple.subject.ty.as_deref(), Some("user"));
assert_eq!(triple.subject.value.as_deref(), Some("jack"));
assert_eq!(triple.predicate.value.as_deref(), Some("message"));
assert_eq!(triple.object.ty.as_deref(), Some("user"));
assert_eq!(triple.object.value.as_deref(), Some("jill"));Re-exports§
pub use tagger::LexiconTagger;pub use tagger::Tagger;
Modules§
- tagger
- Part-of-speech tagging. Ports the tagging half of
lib/text/classify.js. - text
- Text normalization helpers.
Structs§
- Nl3
- A configured nl3 client. Create one with
Nl3::builder. Ports the instance returned by thecreatefactory inindex.js. - Nl3Builder
- Builder for
Nl3. - Predicate
- The predicate (relation) of a triple.
- Term
- One end of a triple — a subject or an object.
- Triple
- A parsed Subject–Predicate–Object triple.
Enums§
- Ambiguity
- How to resolve an entity type that the grammar leaves ambiguous.
- Parse
Error - An error produced while parsing a phrase into a triple.