liveBook · Manning

Formal language

As explained in Natural Language Processing in Action, Second Edition

A formal language is a language defined by strict rules specifying how valid statements are composed and interpreted.

A formal language defines valid statements through strict rules for composing and interpreting symbols. Like a lock that accepts one correct sequence, it lets a machine recognize a command and produce a specific response. Mathematics, programming expressions, regular expressions, and some natural-language patterns can all use formal-language rules. section 1.4.1

Recognizing a chatbot greeting

A chatbot can match the phrase “Hello, Rosa” with a regular expression, trigger a scripted greeting, and extract useful information from the user’s statement. The same pattern-matching approach can recognize commands that unlock actions. section 1.4.1 section 1.4.2

Formal languages support several related operations:

  • Define acceptable sequences with grammars, including regular grammars. section 1.4.1 section 1.4.2
  • Match character sequences in search tools or user statements. section 1.4.2
  • Represent processing as a finite-state machine or deterministic finite automaton. section 1.4.2
Figure 1.4 Kinds of automata
figure

Compare how formal languages used to program finite-state automata are nested within kinds of automata. section 1.4.2

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines grammars, matching, extraction, and finite-state machines, while deferring detailed FSM theory and mathematics.
Examples
Uses lock sequences, chatbot greetings, search matching, grep, and pattern-based chatbot systems as concrete examples.
What you can do after
Apply it via regular expressions to match phrases, extract information, and trigger scripted responses.
How it connects
Connects formal languages with natural language, regular expressions, regular grammars, finite-state automata, and deterministic finite automata.

Also explained in

Compare how 2 books explain formal language →

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.