vim の erlang 用辞書ファイルを Web::Scraper で作る

やっつけだけど動く。Web::Scraper 便利すぎ!

#!/usr/bin/env perl

use strict;
use warnings;

use List::MoreUtils qw(uniq);
use URI;
use Web::Scraper;

my $scraper = scraper {
    process '//html/body/p/table/tr/td[3]/a', 'functions[]' => 'text';
    result 'functions';
};

my @functions;
for ('a'..'z') {
    my $scraped_functions = $scraper->scrape(URI->new(
        'http://www.erlang.org/doc/permuted_index/pidx' . $_ . '.html'
    ));
    push @functions, @$scraped_functions;
}

print $_, "\n" for sort {$a cmp $b} uniq map {s{/\d+$}{};$_;} @functions;

~/.vim/dict の下に辞書ファイルを勝手に作る版はこちら