Probabilistic Scraping of Plain Text Tables
edinburghhacklab.com
edinburghhacklab.com
"Probabalistic Scraping of Plain Text Tables"
vs the submitted title, "Accurate, efficient and maintainable scrapers"
As someone who's scraped a lot of plain text government data, I've given up on finding a flexible machine-learning way and just hand-coded for specific usecases (because government software changes so rarely). However, the OP presents an interesting strategy (with math that I haven't quite mastered, unfortunately)
if you understand how to force boolean algebra into intger form, like:
x + y >= 1, where x={0,1}
is a boolean OR between x, y, then it is easy to expressed in PuLP like:
x = variable("x", lowerbound=0,upperbound=1, cat='Integer') y = variable("y", lowerbound=0,upperbound=1, cat='Integer')
problem += x + y >= 1
tada its really easy to write (once the math is defined, the modelling bit is the hard part, but it gets easier over time)
I've gotten very frustrated writing rules and regexes and exceptions. This method seems really great when scraping data which is structured but a little bit noisy.
yeah so you could extend that tree decision processes this. You could add a cost function on the trees, which includes long range communication between nodes (e.g. the results section of a document includes at least one word commonly associated with results). So you could go to higher levels of abstractions.
However, I say limiting yourself to even a very abstract parse tree structure does kinda exclude the spatial layout of words on a page and the semantic meaning behind the layout (tables, web pages, code formatting!).
MIPs can fully express tree logic so you lose nothing.
This is awesome. What are some other use cases for this?
With APIs much of the data I use has already been formatted in JSON or CSV already, so I don't get to scrape much anymore.
I heard from a colleague who moved into finance, that there's a mini arms race going on between some funds(?) who are subject to regulatory requirements to release financial performance metrics but for a variety of reasons would rather not (and certainly would rather not make the data machine readable), and other hedge funds who want to run automated trading strategies off said released figures.
They keep obfuscating the tables to make them harder and harder to parse algorithmically while still remaining theoretically human-readable.
Great fun no doubt for everyone involved.