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
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • Why Whole-Document Sentiment Analysis Fails and How Section-Level Scoring Fixes It
  • Google Cloud Document AI Basics
  • How to Convert Between PDF and TIFF in Java
  • Thumbnail Generator Microservice for PDF in Spring Boot

Trending

  • Before You Microservice Everything, Read This
  • Understanding the 5 Levels of LeetCode to Crack Coding Interview
  • Scrum Smarter, Not Louder: AI Prompts Every Developer Should Steal
  • Effective Exception Handling in Java and Spring Boot Applications

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 user avatar
Tim Spann
DZone Core CORE ·
Jan. 23, 18 · Tutorial
Likes (8)
Comment
Save
Tweet
Share
15.3K Views

Join the DZone community and get the full member experience.

Join For Free

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

  • Why Whole-Document Sentiment Analysis Fails and How Section-Level Scoring Fixes It
  • Google Cloud Document AI Basics
  • How to Convert Between PDF and TIFF in Java
  • Thumbnail Generator Microservice for PDF in Spring Boot

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: