NLP/L3

From WikiZMSI

< NLP

Regular Expressions

For this part please use the instruction from Natural Language Processing with Python textbook chapter three.

Work with sections by reading the text and copying commands given in the tutorial:

  • 3.4 Regular Expressions for Detecting Word Patterns
  • 3.5 Useful Applications of Regular Expressions


Excercises

1. Describe the class of strings matched by the following regular expressions. Test your answers using nltk.re_show().

[a-zA-Z]+
[A-Z][a-z]*
p[aeiou]{,2}t
\d+(\.\d+)?
([^aeiou][aeiou][^aeiou])*
\w+|[^\w\s]+

2. Write regular expressions to match the following classes of strings:

A single determiner (assume that a, an, and the are the only determiners).
An arithmetic expression using integers, addition, and multiplication, such as 2*3+8.