Coder Social home page Coder Social logo

breadability's Introduction

breadability - another readability Python port

I've tried to work with the various forks of some ancient codebase that ported readability to Python. The lack of tests, unused regex's, and commented out sections of code in other Python ports just drove me nuts.

I put forth an effort to bring in several of the better forks into one codebase, but they've diverged so much that I just can't work with it.

So what's any sane person to do? Re-port it with my own repo, add some tests, infrastructure, and try to make this port better. OSS FTW (and yea, NIH FML, but oh well I did try)

This is a pretty straight port of the JS here:

Installation

This does depend on lxml so you'll need some C headers in order to install things from pip so that it can compile.

sudo apt-get install libxml2-dev libxslt-dev
pip install breadability

Usage

cmd line

$ breadability http://wiki.python.org/moin/BeginnersGuide

Options

  • b will write out the parsed content to a temp file and open it in a browser for viewing.
  • f will override the default behaviour of getting an html fragment (<div>) and give you back a full <html> document.
  • v will output in verbose debug mode and help let you know why it parsed how it did.

Using from Python

from breadability.readable import Article
readable_article = Article(html_text, url=url_came_from)
print readable_article

Work to be done

Yep, I've got some catching up to do. I don't do pagination, I've got a lot of custom tweaks I need to get going, there are some articles that fail to parse. I also have more tests to write on a lot of the cleaning helpers, but hopefully things are setup in a way that those can/will be added.

Fortunately, I need this library for my tools:

so I really need this to be an active and improving project.

Off the top of my heads todo list:

  • Support metadata from parsed article [url, confidence scores, all candidates we thought about?]
  • More tests, more thorough tests
  • More sample articles we need to test against in the test_articles
  • Tests that run through and check for regressions of the test_articles
  • Tidy'ing the HTML that comes out, might help with regression tests ^^
  • Multiple page articles
  • Performance tuning, we do a lot of looping and re-drop some nodes that should be skipped. We should have a set of regression tests for this so that if we implement a change that blows up performance we know it right away.
  • Get up on pypi along with the rest of the ports
  • More docs for things, but sphinx docs and in code comments to help understand wtf we're doing and why. That's the biggest hurdle to some of this stuff.

Helping out

If you want to help, shoot me a pull request, an issue report with broken urls, etc.

You can ping me on irc, I'm always in the #bookie channel in freenode.

Important Links

Inspiration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.