Natural Language Processing · free preview
Text Normalization and Regular Expressions
The normalization pipeline, the regular expression operators, capture groups and substitutions, and sentence segmentation pitfalls.
1. Text Normalization and Regular Expressions
Text Normalization and Regular Expressions
2. The regular expression operators
The regular expression operators
3. Tokenizing and rewriting with Python's re module
Tokenizing and rewriting with Python's re module
4. Reading a pattern
Which of these strings matches the regular expression D[a-z]{4}\d{2} (anchors omitted, so a match can occur anywhere)?
5. Counting matches
How many substrings of this log line match \d{3}-\d{4}?
"99-5981; 183-6326; 823-7318; 8789-6672; 256-9285."
6. Rewriting with capture groups
The substitution re.sub(r"(\w+) (\d+) (\w+)", r"\3-\1", s) is applied to s = "bay 09 south". What is the resulting string? (Type it exactly, lowercase.)
7. Word boundaries
Which of these strings contains a match for the pattern \bwake\b?
8. Counting the language of a pattern
How many strings of length 7 over the alphabet {0,1} end with 10? (That is, strings matching (0|1)*10 with total length exactly 7.)
Practice this interactively
Free account · instant grading · spaced review that schedules itself.
Start this course for free