src.pipeline.nlu

Submodules

Classes

SimpleNLU

Simple Natural Language Understanding component.

SpacyNLU

Enhanced Natural Language Understanding component

Package Contents

class SimpleNLU[source]

Simple Natural Language Understanding component. Uses keyword matching for intent recognition.

patterns
get_intent(text: str) str[source]

Extract intent from normalized text.

Parameters:

text – Normalized user input

Returns:

Intent name as string

class SpacyNLU(model='en_core_web_sm')[source]

Enhanced Natural Language Understanding component with advanced intent recognition and entity extraction.

intent_patterns
_fuzzy_match(text: str, patterns: List[str], threshold: float = 0.6) bool[source]

Perform fuzzy matching of text against patterns.

Parameters:
  • text – Input text to match

  • patterns – List of pattern strings

  • threshold – Similarity threshold

Returns:

Boolean indicating if a match is found

get_intent(text: str) Dict[str, Any][source]

Extract intent with more context and details.

Parameters:

text – User input text

Returns:

Dictionary with intent details

_extract_entities(doc) Dict[str, List[str]][source]

Extract named entities from the processed document.

Parameters:

doc – spaCy processed document

Returns:

Dictionary of extracted entities

add_custom_intent(name: str, keywords: List[str], patterns: List[str] = None)[source]

Allow dynamic addition of intent patterns.

Parameters:
  • name – Name of the intent

  • keywords – List of keywords for the intent

  • patterns – Optional list of pattern strings