Google Refine + Perl (English)
Google Refine is awesome. If you're unaware of what it is, access their official page and watch at least the first screencast. You'll see it can be helpful for several ETL-related tasks.
Currently, I use it a lot, specially for simple (but boring) tasks, like loading a CSV, trimming out some outliers and saving as JSON to be imported into MongoDB. Nothing a Perl one-liner couldn't do.
However, the opposite is not true: Perl one-liners are a lot more flexible than Google Refine. Now, what if we could merge both?
- Google Refine could be easily integrated with any RESTful API.
- Perl transforms one-liners into RESTful webservices.
- PROFIT!!!
As a practical example, I'll use some georeferenced data I was working at. Let's suppose I have to deduplicate registers, and one of "duplicate" rules is their proximity on the map. Google Refine is far from a full-featured GIS, and is unable to handle bidimensional coordinate system. Enter the GeoDNA: an algorithm to lower geospatial dimensions. As it's FAQ says,
GeoDNA is a way to represent a latitude/longitude coordinate pair as a string. That sounds simple enough, but it's a special string format: the longer it is, the more accurate it is. More importantly, each string uniquely defines a region of the earth's surface, so in general, GeoDNA codes with similar prefixes are located near each other. This can be used to perform proximity searching using only string comparisons (like the SQL "LIKE" operator).
Another interesting property of GeoDNA is that when ordening a set of records by their GeoDNA code, close locations are likely to appear in adjacent rows (sometimes, close locations will share very different prefixes, but similar prefixes always represent close locations).
To incorporate GeoDNA into Google Refine, we'll use the Add column by fetching URLs option, clicking on the header of any column (which column it will be doesn't matter as we'll use two of them, anyway):
As the expression, we'll paste the following code (here, pay attention to the correct latitude/longitude column names):
'http://127.0.0.1:3000/?lat='+ row.cells['latitude'].value +'&lon='+ row.cells['longitude'].value
Throttle delay can be zeroed, as our webservice is local. The final configuration should look like this (don't push the OK button, yet):
Now, check if you have Mojolicious and Geo::DNA Perl modules (install them via CPAN, if not) and paste into your terminal:
perl -MGeo::DNA -Mojo -E 'a("/"=>sub{my$s=shift;$s->render(json=>{geocode=>Geo::DNA::encode_geo_dna($s->param("lat"),$s->param("lon"))})})->start' daemon
If you prefer a "human-readable" version, paste the following code into geocode-webservice.pl:
#!/usr/bin/env perl use Geo::DNA qw(encode_geo_dna); use Mojolicious::Lite; any '/' => sub { my $self = shift; $self->render(json => { geocode => encode_geo_dna( $self->param('lat'), $self->param('lon'), ), }); }; app->start;
Once you started a webservice, it will report Server available at http://127.0.0.1:3000. Now, click OK on Google Refine dialog and wait. Even without delay, it could be a bit slow; however, even then this hack saved me a lot of time
Ampersand: Proposta de um novo paradigma para as Interfaces Homem-Máquina
Ampersand
Proposta de um novo paradigma para as Interfaces Homem-Máquina
Autor:
Stanislaw Pusep, designer & developer.
Sobre:
Pré-protótipo da proposta resultante do Projeto de Conclusão de Curso de Desenho Industrial – Projeto do Produto, da Faculdade de Arquitetura, Artes e Comunicação da Unesp - Campus Bauru, realizado sob a orientação do Prof. Dr. Luis Carlos Paschoarelli.
Página do projeto, com o (b)log do desenvolvimento, monografia, código-fonte, etc.: http://sysd.org/category/design/chi/tcc/
Preview:
Inicialização:
Esta demonstração foi implementada utilizando os recursos multitouch do Adobe AIR 2, que, no período do desenvolvimento, encontrava-se em estágio beta.Portanto, caso o seu sistema não tenha os runtimes compatíveis, prossiga da seguinte maneira:
- Baixe a versão mais recente do Adobe AIR 2 SDK da página oficial do Adobe Labs: http://labs.adobe.com/downloads/air2.html;
- Extraia o conteúdo para a pasta
"SDK"dentro da pasta do projeto (o importante é que"SDK\bin"contenha o arquivo"adl.exe"e"SDK\runtimes\air\win"conhenha a pasta"Adobe AIR"); - Execute o arquivo
Ampersand.cmd.
Funcionamento:
Esta versão opera tanto através do mouse quanto multitouch presente em Windows Vista e Windows 7. Se o seu hardware não suporta multitouch nativamente, pode experimentar o Multi-Touch Vista com múltiplos mouses ou através de uma interface TUIO/OSC (tal como o OSCemote).
- A demonstração roda em tela cheia; para sair, é só dar
Alt-F4; - No desktop inicial, somente links para "apresentação" e "email" foram implementados;
- A navegação é feita por um toque simples ou clique nos widgets hexagonais;
- Para a visão geral, ou "minimização" dos widgets, utilize o clique com o botão direito ou o gesto de fechar a pinça (zoom out);
- Para trocar a tipografia de 16 segmentos para a de 6 segmentos, utilize o clique com o botão do meio ou o gesto press and tap;
- Para testar a digitação, vá para "email", aponte um campo de entrada de texto e utilize o seletor de caracteres;
- Para rotacionar o seletor de caracteres, utilize a rodinha do mouse ou o gesto de rotação.
Copyright:
- Ampersand - GNU LESSER GENERAL PUBLIC LICENSE
- PICOL (PIctorial COmmunication Language): Creative Commons-License BY-SA
- Transponder AOE font by Astigmatic One Eye
- Wikipédia: Creative Commons-License BY-SA
Attached Files:
Ampersand.zipO aplicativo da demonstração mais o código-fonte compilável em Adobe Flash CS4.


