# NER and context mapping

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 has to be executed within 1 Month. you have to pay \$3000 as contract fee, \$60 as taxes, \$1200 as security deposit and \$1200 as rent

Expected output : Contract tenure : 3 Months, Amount to pay : \$3060 Please note : I tried NER but that is showing 2 tenured and 2 amounts. However I am looking for a technique by which we can associate amount to contract. ## 1 Answer Standard NER is going to extract individual entities, which in this case is time (3 months, 1 month) and currency ($3000, etc). You'll also want to think about Relationship Extraction, which identifies how two pieces of text relate to one another. For example, from a Euclidean distance measure, "contract" is related to "valid" and "executed", and "valid" is related to "3 months" while "executed" is related to "1 month". Based on what you said your desired output should be, you'll want to train your model to calculate the shortest distance between "contract" and "3 months", which in this case means teaching it to look for "valid" while ignoring "executed". There are different ways of doing this which you'll want to think about in terms of what works best for your corpus of text.

Here's a link to get you started (also includes links to other resources).

• Thanks but above approach explains the relationship within the sentence however in above problem I am trying to establish relationship between the sentences.
– SKB
Apr 28 '20 at 4:17
• You can build the model to identify that "contract" in sentence 1 is the same as the "contract" in sentence 2. In which case then, "contract" becomes a single entity to build relationships. For example, using spacy's EntityRuler and EntityRecognizer in some customized pipeline.
– Cat
Apr 28 '20 at 13:35
• Thanks @Cat C, I have trained SpaCy Entity recognizer model to do this but it's sees to be heavily position dependednt while doing parsing. So giving her poor results. It would be big help if you have some ready reference or sample code available.
– SKB
Apr 29 '20 at 11:32