# Text mining from PDF documents and results places

**URL:** <https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186>\
**Category:** KNIME Extensions\
**Tags:** text-processing\
**Created:** [October 18, 2022, 1:24pm UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186 "2022-10-18T13:24:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![janszky\_nav](https://forum-cdn.knime.com/user_avatar/forum.knime.com/janszky_nav/32/46158_2.png) [@janszky\_nav](https://forum.knime.com/u/janszky_nav)\
**Post date:** [October 18, 2022, 1:24pm UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/1 "2022-10-18T13:24:13Z")

</div>

Hello everyone,

I would like to ask for some help with a text search.

I have some long PDF files in which I would like to search for words.

Is there a way to export the places/rows results of the search?

I would like to see which page/row the results are on.

For example, the text I searched for text (like volvo).

And the results will be listed on a different page where I can see which rows of the documents contains that word „volvo” (e.g.: 2. page, 5. page, 13. page etc.)

Thank you for instance!

Tamas

---

<div class="post-metadata">

**Author:** ![victor\_palacios](https://forum-cdn.knime.com/user_avatar/forum.knime.com/victor_palacios/32/37922_2.png) [@victor\_palacios](https://forum.knime.com/u/victor_palacios)\
**Post date:** [October 21, 2022, 4:32pm UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/2 "2022-10-21T16:32:09Z")

</div>

There is no easy way to do that (which I know), but why would you want to do this? Are you trying to see the context in which the word Volvo was used for instance? You could do that with a context window. See the challenge 38 of Just KNIME It to do so.

> [@Solutions to "Just KNIME It!" Challenge 38](https://forum.knime.com/t/solutions-to-just-knime-it-challenge-38/48048/6):
>
> Hi everyone, here is my solution. It only finds the first instance of the lookup word. I also share component named “Word Window” on hub. Lookup word and window length can be configured from component.

If you want general information on how to extract from a PDF here is the webinar I ran in August:

> [@Webinar: PDF Text Extraction using KNIME, Regex, and Python- August 17, 2022](https://forum.knime.com/t/webinar-pdf-text-extraction-using-knime-regex-and-python-august-17-2022/46049):
>
> Join @victor_palacios for the webinar " PDF Text Extraction using KNIME, Regex, and Python" on Wednesday, August 17 at 5 PM - 6 PM UTC +2 (Berlin) which is 10 AM - 11 PM UTC -5 (Chicago) [HERE IS THE RECORDING](https://knime.wistia.com/medias/30jiddrbwd)[PDF Extraction Webinar Slides](https://forum.knime.com/uploads/short-url/qt7ZHAlYYZutIxXaLwvHawX6DSg.pptx) In this webinar, we will parse PDF documents using the no-code, free tool KNIME and integrate it with code-based tools - Regex and Python. PDFs bring a number of unique challenges. For instance, how do we know if the PDF is text-based or image-based? If te…

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [October 21, 2022, 5:56pm UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/3 "2022-10-21T17:56:54Z")

</div>

@janszky_nav I adapted an older example ([How to read multiple lines from PDF File - #6 by mlauber71](https://forum.knime.com/t/how-to-read-multiple-lines-from-pdf-file/46510/6)) using R code to extract the text from PDF files and then search for the page and line where a special word (in this case “Procter”) would appear.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/5/8/587bf806b673fdb2846ab502e64519d597c173f9.png)

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/d/9dc12dbd91f23a8f5a1eab8a93fe95c1b5c9e5de.png)

> **[use R and KNIME to extract text from PDF file - search for page where text...](https://hub.knime.com/mlauber71/spaces/Public/kn_example_r_pdf_read_text~NCmYaa3cn4lEHyUR/current-state)**
>
> use R and KNIME to extract text from PDF file - search for page where text appears

–  
Edit: [KNIME — Extract Text and Tables from PDF Files with Python in a Low-Code Environment | by Markus Lauber | Low Code for Data Science | Medium](https://medium.com/low-code-for-advanced-data-science/knime-extract-text-and-tables-from-pdf-files-with-python-in-a-low-code-environment-e2949a95e3fc)

---

<div class="post-metadata">

**Author:** ![ersy](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/e/71c47a/32.png) [@ersy](https://forum.knime.com/u/ersy)\
**Post date:** [October 22, 2022, 3:58pm UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/4 "2022-10-22T15:58:57Z")

</div>

I want to do some string manipulation not word embeddings or other text-processing. I just made it up for the challenge like a small lab for string, characters, punctuation and word manipulation etc., 🙂  
Thanks for the webinar info.

---

<div class="post-metadata">

**Author:** ![janszky\_nav](https://forum-cdn.knime.com/user_avatar/forum.knime.com/janszky_nav/32/46158_2.png) [@janszky\_nav](https://forum.knime.com/u/janszky_nav)\
**Post date:** [October 27, 2022, 8:40am UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/5 "2022-10-27T08:40:47Z")

</div>

Dear mlauber71,  
Thank you your solution.

---

<div class="post-metadata">

**Author:** ![janszky\_nav](https://forum-cdn.knime.com/user_avatar/forum.knime.com/janszky_nav/32/46158_2.png) [@janszky\_nav](https://forum.knime.com/u/janszky_nav)\
**Post date:** [October 27, 2022, 1:31pm UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/6 "2022-10-27T13:31:06Z")

</div>

Dear Victor,

Thank you for your answer, it was very usful, and I saw the Webinar too.  
Thank you.

May I have one more question?

If I have some pdf-s like the sample and I would like to extract text message/call data such as numbers and text.  
The call text is located before the text **“A jogosult ügy…”**.  
Whic one cell splitter the best option?

Thank you.  
[20221027\_split\_part\_of\_text.knwf](https://forum.knime.com/uploads/short-url/1ubd9tucYTpETUwXf1fw3PL2Rjh.knwf) (39.6 KB)  
This is a sample pdf, unfortunatley i can’t upload the pdf file. Sorry.  
[KNIME\_PDF\_Sample\_m.txt](https://forum.knime.com/uploads/short-url/bMrNnqsW5xus9A9nWUpZKA1akCy.txt) (316.4 KB)

---

<div class="post-metadata">

**Author:** ![victor\_palacios](https://forum-cdn.knime.com/user_avatar/forum.knime.com/victor_palacios/32/37922_2.png) [@victor\_palacios](https://forum.knime.com/u/victor_palacios)\
**Post date:** [October 27, 2022, 4:23pm UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/7 "2022-10-27T16:23:08Z")

</div>

I would target the phrase “A jogosult ugy” and then extract 20-30 characters (or more) after it. Then get the data you want from that window.

Unfortunately, the data in the txt file seems corrupted?

![Screen Shot 2022-10-27 at 9.23.58 AM](https://forum-cdn.knime.com/uploads/default/original/3X/3/0/300bd64f6617abe5cc74b00c3cd7f20c01f5164a.png)

To do the window targeting, I would use Regex.

Here is my cheat sheet for Regex:

> **[Various Examples of Regex in KNIME – victor\_palacios](https://hub.knime.com/victor_palacios/spaces/Public/latest/Various%20Examples%20of%20Regex%20in%20KNIME~J1anMyaS7MMiRV29)**
>
> Solutions for data science: find workflows, nodes and components, and collaborate in spaces.

Here is what you can use to target that text and extract words after it:

 ![Screen Shot 2022-10-27 at 9.25.56 AM](https://forum-cdn.knime.com/uploads/default/original/3X/1/e/1e1442e15bacc9450736e650aeef068b85f129cc.png)

Finally, challenge 38 from Just KNIME It! may help you accomplish the same task.

---

<div class="post-metadata">

**Author:** ![janszky\_nav](https://forum-cdn.knime.com/user_avatar/forum.knime.com/janszky_nav/32/46158_2.png) [@janszky\_nav](https://forum.knime.com/u/janszky_nav)\
**Post date:** [October 28, 2022, 5:21am UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/8 "2022-10-28T05:21:16Z")

</div>

No, it isn’t corrupted. It is a pdf, i simply change the file extension. (pdf-\>txt)

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [November 4, 2022, 5:21am UTC](https://forum.knime.com/t/text-mining-from-pdf-documents-and-results-places/48186/9 "2022-11-04T05:21:49Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
