DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • A Deep Dive into the Microsoft Foundry Document Intelligence SDK: From PDF to Structured Data
  • Document Generation API: How to Automate Personalized Document Creation at Scale
  • Extracting Clean Excel Tables From PDFs Using Python + Docling
  • AI-Powered Knowledge: LlamaIndex and Apache Tika for Enterprises

Trending

  • Moving 900+ GB of Prometheus Without a Cutover Weekend
  • Part 1: Building Governed MCP Tool Services With Quarkus LangChain4j and Goose
  • Kafka With Spring Boot: Introduction
  • Evals in CI: How to Catch Agent Regressions Before Production Does

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

Apache Tika and Apache OpenNLP for Easy PDF Parsing and Munching

Learn how to parse PDFs with ease — and without any code — using the updated Apache Tika and Apache OpenNLP processors for Apache 1.5.

By 
Tim Spann
DZone Core CORE ·
Jan. 23, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
16.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

I have just started working on updated Apache Tika and Apache OpenNLP processors for Apache 1.5 and while testing, I found an interesting workflow that I would like to share.

I am using a few of my processors in this flow:

  • Attribute Cleaner (just updated)
  • Apache OpenNLP Processor
  • Apache Tika Processor (this needs a major version refresh)

Here is the flow that I was working on:

  • Load some PDFs.

  • Use the built-in Apache Tika processor to extract metadata from the files.

  • Pull out the text using your Apache Tika processor.

  • Split this into individual lines.

  • Extract out the text of the line into an attribute (i.e. (^.*$)) into a sentence.

  • Run NLP to analyze names and locations on that sentence.

  • Run Stanford CoreNLP sentiment analysis on the sentence.

  • Run your attribute cleaner to turn those attributes into AVRO safe names.

  • Turn all the attributes into a JSON Flow File.

  • Infer an Avro schema (I only needed this once; then, I'll remove it).

  • Set the name of the Schema to be looked up from the Schema Registry.

  • Run QueryRecord to route positive, neutral, and negative sentiments to different places. Example SQL: SELECT * FROM FLOWFILE WHERE sentiment = 'NEGATIVE'. Thanks, Apache Calcite! We also convert from JSON to Avro to send to Kafka, as well as for easy conversion to Apache ORC for Apache Hive usage.

  • Send records to Kafka 1.0. Some are merged to store as files and some are made into Slack messages.

  • Done!

Here is an example of my generated JSON file.

Here are some of the attributes after the run.

You can see the queries in the QueryRecord processor.

The results of a run showing a sentence, file metadata, and sentiment.

We are now waiting for new PDFs (and other file types) to arrive in the directory for immediate processing.

I have a JSONTreeReader, a Hortonworks Schema Registry, and AvroRecordSetWriter.

We set the properties and the schema registry for the reader and writer. Obviously, we can use other readers and writers as needed for types like CSV.

When I'm done, since it's Apache NiFi 1.5, I commit my changes for versioning.

For the upcoming processor, I will be interfacing with OCR, NER, NLTK, Grobid quantities, MITIE, age detection, vision, deep learning, and image captioning with Apache Tika.

Apache Tika has added some really cool updates, so I can't wait to dive in.

Apache Tika Apache OpenNLP PDF OpenNLP

Opinions expressed by DZone contributors are their own.

Related

  • A Deep Dive into the Microsoft Foundry Document Intelligence SDK: From PDF to Structured Data
  • Document Generation API: How to Automate Personalized Document Creation at Scale
  • Extracting Clean Excel Tables From PDFs Using Python + Docling
  • AI-Powered Knowledge: LlamaIndex and Apache Tika for Enterprises

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook