src.pipeline.nlu.spacy_nlu

Classes

SpacyNLU

Enhanced Natural Language Understanding component

Module Contents

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

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

intent_patterns[source]
_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