I am trying to read a PDF file and put it in Python string and trying to fetch information based on keywords. The text here is completely irregular.

Example of text

Blockquote Ram has taken an insurance of his premises with total sum insured of INR 256,200,000,000. XYZ company provides an insured with limit of liability of INR 100,250,000 and 90 days indemnity period. Insured with deductible of INR 200,000.

Here I want to find 3 things from this text

  • limit of liability amount
  • Deductible amount
  • Sum insured amount

For example

Limit of liability = 100,250,000

  • $\begingroup$ What is your specific question? What have you tried so far? $\endgroup$
    – nbro
    Mar 29, 2021 at 10:27

1 Answer 1


If the text is really that regular, you can do simple pattern matching: Search for the keywords "limit of liability", "deductible", and "sum insured". The take the next numerical value (possibly preceded by "INR"), and assign it to the corresponding value.

However, this is very simplistic and brittle, and will fail if the texts are more varied. You might still get quite far with it, and you can always add more variations of the keywords to it.

Note that I would not advise that for general text analysis, as it's far too primitive.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .