Checking a value against a pattern

Anyone who has ever used word processing programs has had to face the problem of searching for a text string within the period. Perhaps without knowing it, we came across the pattern matching problem. Pattern matching is a procedure in which you check whether a token sequence has a certain pattern, that is, a combination of characters that respects a certain pattern.

A lexical token, or simply token, is a string with an assigned and thus identified meaning. It is structured as a pair consisting of a token name and an optional token value. The token name is a category of lexical unit.

As for the interpretation of the inputs by a chatbot, pattern matching can be useful for recognizing certain message sets. For example, thanks to pattern matching, you can answer Hello! to all the messages that contain the word hello or hi; or you can recognize that a message is of question type by checking whether the last token is ?.

A very useful tool for pattern recognition is regular expression, which offers a notation system for identifying sets of strings.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.56.45