1 / 1

Lecture 3 Summary

Lecture 3 Summary. Regular Expressions (continued from the previous lecture) 1. Disjunction : e.g. /cat|dog/ matches either the string cat or the string dog 2. Grouping : e.g. /gupp(y|ies)/ applies disjunction only to suffixes y and ies

petra
Download Presentation

Lecture 3 Summary

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3 Summary • Regular Expressions (continued from the previous lecture) • 1. Disjunction : e.g. /cat|dog/ matches either the string cat or the string dog • 2. Grouping : e.g. /gupp(y|ies)/ applies disjunction only to suffixes y and ies • Precedence : Idea that one operator may take precedence over another is formalized by the operator precedence hierarchy • Advanced operators with examples : • a. Aliases for common sets of characters e.g. \w – any alphanumeric or space • b. Explicit numbers as counters e.g. /ab{24}z/ matches a followed by 24 b’s followed by z • c. Special characters are referred to using backslash (\) e.g. newline character \n • Substitution and memory in regular expressions • a. Substitution : s/regexp1/regexp2/ allows string characterized by one expression to be replaced by a different regular expression e.g. s/colour/color/ • b. Number operator : It is used to refer back to a particular subpart of a string using numbered memories called registers • e.g. /the (.*)er they (.*), the \1er they \2/ will match the bigger they were, the bigger they were but not the bigger they were, the bigger they will be • c. Subtitutions using memory are very useful in implementing NLP e.g. ELIZA

More Related