liveBook · Manning

String match

As explained in Natural Language Processing in Action, Second Edition

String matching is the process of finding exact or approximate occurrences or correspondences between character sequences.

String matching compares character sequences to find exact or approximate correspondences. It supports useful NLP behavior even when no machine learning, tokenization, or feature generation is involved. section 1.4.2 section 1.9

Regular expressions provide a compact rule language for matching patterns. Their regular-language foundation is efficiently parsable, while finite-state machines clarify the kinds of patterns these rules can recognize. section 1.4.2

Common matching strategies include:

  • Use regular-expression rules to recognize input patterns for question answering and task-execution assistants. section 1.9
  • Use edit distance to rank stored statements by similarity, then reuse the response paired with the closest match. section 1.9

A minimal chatbot pipeline

ChatterBot computes the Levenshtein distance between an input statement and stored statements, then uses brute-force search to select a corresponding reply. Will takes a different approach, matching programmed regular expressions for a data-light assistant. section 1.9

Figure 1.4 Kinds of automata
figure

Use the automata diagram to relate regular expressions and finite-state machines to progressively more expressive computational models. section 1.4.2

Figure 1.8 Example layers for an NLP pipeline
figure

Use the NLP-layer diagram to place string matching near the text-processing surface of chatbot and language-processing pipelines. section 1.9

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Connects regular expressions to efficiently parsable regular languages, then demonstrates brute-force edit-distance retrieval without tokenization.
Examples
Shows ChatterBot statement retrieval, Will regular-expression rules, and Salvius conversational behavior.
What you can do after
Apply string matching to retrieve responses by brute-force search or route assistant inputs through regular-expression rules.
How it connects
Links regular expressions, finite-state machines, edit distance, chatbots, semantic search, and question answering.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.