Natural Language Processing · 免费预览

文本归一化与正则表达式

归一化流水线、正则表达式运算符、捕获组与替换,以及句子切分中的陷阱。

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.)

进入交互式练习

免费注册 · 即时批改 · 自动安排间隔复习。

免费开始这门课