liveBook · Manning

Machine learning

As explained in Natural Language Processing in Action, Second Edition

Machine learning is a computational approach in which algorithms derive patterns or behavior from data rather than relying solely on explicitly programmed rules.

Machine learning lets an NLP system learn patterns from data instead of relying on a programmer to specify every rule. Natural language makes that useful: a regular expression can match a precise character pattern, but recognizing what varied statements mean calls for more than handcrafted matches. section 1.1 section 1.5.2

For a chatbot, the practical difference is how you provide the behavior:

  • With handcrafted rules, you anticipate spellings, capitalization, and phrasing, then add patterns to handle them. This remains useful for precise, command-like input. section 1.5.2
  • With machine learning, you supply labeled examples of user statements and desired responses. The resulting behavior depends heavily on the quality of those examples; you need not write a branch for every phrasing. section 1.10

From greeting rules to sentiment scores

A greeting matcher can grow from a simple regular expression into a collection of exceptions for names, typos, and alternative greetings. Sentiment analysis offers a second comparison: instead of manually assigning scores to keywords, train a model on statements or documents labeled with the sentiment to predict a numerical score for new text. Both approaches require care: even sophisticated NLP pipelines can be brittle when their datasets do not cover the text they encounter. section 1.5.2 section 2.6

Machine learning can support a chatbot pipeline that extracts features, finds information, searches documents, and generates responses. More domain data can improve what such a pipeline can handle, but plausible generated responses are not necessarily correct or helpful. Evaluate responses against the chatbot’s goals rather than treating fluent output as proof of understanding. section 1.10 section 1.8

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains the labeled-data approach through contrasts with rules and regular expressions, but defers model-building details.
Examples
Contrasts greeting-matching regular expressions with learned chatbot responses, then compares keyword-based and learned sentiment scores.
What it assumes
Introduces learned text patterns through familiar programming rules and regular expressions, without requiring model internals.
What you can do after
Evaluate/understand when labeled examples may serve an NLP task better than handcrafted rules, while recognizing data-quality and reliability limits.
How it connects
Connects machine learning to regular expressions, labeled datasets, sentiment analysis, deep learning, and NLP pipelines.

Also explained in

Compare how 42 books explain machine learning →

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.