27 comments

[ 5.5 ms ] story [ 72.7 ms ] thread
Apache Tika exists for years and seems to have the same goal: http://tika.apache.org/

I'm wondering why the authors wrote something from scratch ?

edit: this is answered by one author in the 2nd disqus comments of the link

> wrote something from scratch ?

Looking at the source, they didn't lie about “no muss, no fuss”. It just antiword .docs, cat .txt etc

Here's the comment:

"Its very similar to Apache Tika (which I didn't know about until yesterday), but I think it is different in at least two important ways.

"1. The intention of textract is to provide many possible ways to extract text from any document, provided words appear in the correct order in the text output. By being method agnostic, its possible to use different parsing techniques in different situations. Here's more on that philosophy http://textract.readthedocs.or... and, to be fair, I'm not sure that Tika's philosophy differs in any meaningful way on this.

"2. Another subtle difference is that textract is written in python, which is a language that is used by nearly all data people that I know. Since the intent is to be a preprocessing framework for natural language processing, I wanted it to be as maintainable by the community as possible."

The node module by the same name (https://github.com/dbashford/textract) also supports image OCR (via tesseract), excel files, RTF and other formats.
Thanks for pointing this out. I've been working on a text extractor in Go at work and tried for a long time to get UnRTF working with RTF files containing Japanese characters to no avail. This lib lists catdoc as the extractor they use for RTF, so I'm going to give that a try.

Edit: Looks like catdoc doesn't work with RTF files containing Japanese characters either. Might end up having to use libreoffice or something like that.

I also assumed that it was some kind of Python wrapper or implementation of Tesseract OCR when I saw that name. One would think so when Tesseract being (one of?) the best preforming OCR-programs out there.
> Ok, ok, ok. You can’t extract text from any document at the moment, but textract integrates support for many common formats and we designed it to be as easy as possible to add other document formats.

There go my hopes to see painless OCR library for Python…

This looks nice. What I'd really like to see, along these lines, is a python library for automated document metadata extraction with confidence assessment, like this:

./autometa.py --author --verbose academic-paper.pdf

Author: "Edward Witten" Confidence: High (matches template "amslatex")

As far as I have been able to tell, the public state of the art in academic paper metadata parsing is Grobid: https://github.com/kermitt2/grobid

Not quite as simple a commandline interface as you suggest, but not too hard to set up, and pretty impressive. Now if only Google Scholar would open-source whatever they use...

I thought about the metadata thing but decided to exclude it for the earliest versions of textract to keep things simple. If you'd like to see it in there and have a good example of how you'd like to use metadata, please feel free to throw an issue on the issue tracker https://github.com/deanmalmgren/textract/issues/
I realise that it's nice that it'll give you a single function to dump whatever file format into (while actually running it through a shell command in the backend), but it's not that hard to:

  out = ""
  pdf = pyPdf.PdfFileReader(stream)
  try:
      if pdf.getIsEncrypted():
          pdf.decrypt('')
      for page in pdf.pages:
          out += page.extractText()
  except NotImplementedError:
      # Yeah, this ain't happening
i've always thought the datascope team was awesome. textract makes them even awesomer.
I have a little shell script which tries to do basically this:

https://gist.github.com/djudd/1402751e2928cb8ac788

It tries either abiword or OpenOffice/LibreOffice for filetypes other than pdf, ps, and txt, which works pretty decently for doc, docx, ppt, etc.

One file type here that textract folks might want to add is Postscript.

Python version supported? Pypi doesn't list it.

On the same note, your pypi page is borked: https://pypi.python.org/pypi/textract

(look at Build status & co, there's a formatting error)

Currently 2.7 but there's no reason python 3 can't be supported too. Thanks for the heads up on the borking of the pypi page. Noted.
Nice. Does it do any encoding conversion, e.g. latin1 to utf-8? Does Tika do that?
Great tool! BTW. how does this compare to Apache Tika for text extraction from HTML pages?
When I first read the headline, I thought there was a new python API or SDK for the already existing Textract OCR solution from Structurise. We've used Structurise's product called Textract for years at work, so it was definately around first. I'm not sure if the creators of this new solution/product were aware of the prior's existence, but using the same product name for a product that solves a similar problem seems like it would be an issue... or at the very least confusing.

Here's a link to StructuRise's Textract product page: http://www.structurise.com/textract/