Extracting amount from free text

I want to extract various amounts and tenure of contracts from different contract documents that we have.

For example: Mr xyz, this contact is valid for 3 Months and you have to pay $3000 as agreement fee. Expected output : 3 Months,$3000

Please note that this is just an example but the sequence, format, currency and tenure is not fixed in the actual problem.

Named Entity Recognition (NER) models should be able to identify money amounts.

Other NLP techniques such as Dependency Parsing or Constituency Parsing can be used to identify the subject of the sentence - or the person the amount is referred to.

For the months amount, I think once you have other informations that's something you could extract with a "hard coded" script.

I don't know much your data varies but I find that regular expressions can usually solve these sort of problems. In the example you gave you could, for instance, write these Python regular expressions that will extract the contract length and agreement fee.

# Contract Length
re.findall('\d+ (?:Weeks|Months|Years)', 'Mr xyz, this contact is valid for 3 Months and you have to pay $3000 as agreement fee') # Agreement Fee re.findall('\$\d+', 'Mr xyz, this contact is valid for 3 Months and you have to pay \$3000 as agreement fee')


If however, you have more variance in your data, and you are able to label it, then named entity recognition (NER) is something you should definitely look at.

• Thanks Gad for reply but using regex will not be a robust solution for this and any variance in data will fail the model i.e with regex approach it is not clear that amount and agreement are related entities and amount is for the given contract only. NER will also help to isolate amount and tenure but not the relation between the 2. – SKB Apr 23 '20 at 6:48