0

I am working with NLTK and I am trying to chunk (AIM 20-40-60) from the following text:

text = for more information refer to the Business Reporting Policy (AIM 20-40-60)

Currently I am using the following chunk pattern grammar = r"CHUNK:{<NN.*><CD>}" which is able to perfectly capture the AIM 20-40-60 part.

Nevertheless I also want the parenthesis () to be part of the chunk as well and since I am relatively new to regular expressions and chunking, I don't know the exact regEX pattern for capturing the parenthesis.

Cœur
  • 37,241
  • 25
  • 195
  • 267
LoniF
  • 97
  • 1
  • 1
  • 7

1 Answers1

0

The solution is the folloing

grammar = r"CHUNK:{<\(><NNP><CD><\)>}"

LoniF
  • 97
  • 1
  • 1
  • 7