1
$\begingroup$

I have a bunch of documents in which I want to highlight certain paragraphs/keyphrases. I have a list of the most frequently appearing sentences and I want to search for these paragraphs/keyphrases in the document and if they appear, highlight them. The length of these paragraphs/keyphrases will be longer than 3-4 words. Below is an example doc:

sample_image

One approach I am currently trying (and failing) is using Pytesseract. These are the steps:

  1. Use image_to_data function in Pytesseract to extract the words and their bounding boxes (bbox) from the document image.
  2. From the extracted words, find the sentence using re.search().
  3. If there is a match, then store the words and their bbox coordinates in a dictionary and then use cv2.rectangle() to highlight them.

The issue with the above approach is the presence of duplicate words. For example in the above image if I want to highlight the sentence Your acts or omissions. For the words Your, acts and omissions, I am getting the correct coordinates but for the word or, since it is appearing once above the actual sentence (property damage "or" personal and advertising), the actual coordinate of the word or in the sentence Your acts or omissions is being replaced by the coordinates of or appearing in the sentence above property damage "or" personal and advertising.

This is happening for all duplicate keywords appearing. How can I solve this issue? I am also open to any other approach be it AI based or non AI based. Basically I need to highlight certain sentences occuring in a document, that's all!

Thanks in advance!

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.