Skip to content

NlpEntityRegistry

Defined in: core/src/nlp/nlp.entities.ts:26

What a phrase filled, looked up by the slot object itself.

Addressing by slot rather than by name is what makes this typed: a slot carries the type of its own values, so entities.get(room) is a Room[] without anything having to restate that.

Every lookup answers an array. One phrase can fill a single slot several times over — “the kitchen and the hallway lights” — and an interface that answered with one value would have to pick, silently, which of them mattered. A slot the phrase left alone answers [].

Named for the NLP sense of entity, an extracted span. Unrelated to EntityType, which is a searchable record type exposed as a tool.

new NlpEntityRegistry(matches?): NlpEntityRegistry;

Defined in: core/src/nlp/nlp.entities.ts:29

Parameter Type
matches Map<string, NlpEntityMatch<unknown>[]>

NlpEntityRegistry

entries(): [string, NlpEntityMatch<unknown>[]][];

Defined in: core/src/nlp/nlp.entities.ts:47

Every filled slot’s id paired with its matches — for transports that have to serialise this.

[string, NlpEntityMatch<unknown>[]][]


get<T>(slot): T[];

Defined in: core/src/nlp/nlp.entities.ts:34

Every value matched for slot, in the order they appeared in the phrase.

Type Parameter
T
Parameter Type
slot Slot<T>

T[]


has(slot): boolean;

Defined in: core/src/nlp/nlp.entities.ts:44

Whether the phrase filled slot at all.

Parameter Type
slot Slot

boolean


matches<T>(slot): NlpEntityMatch<T>[];

Defined in: core/src/nlp/nlp.entities.ts:41

As NlpEntityRegistry.get, but keeping the matched text and accuracy.

Type Parameter
T
Parameter Type
slot Slot<T>

NlpEntityMatch<T>[]