diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-08 01:34:52 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-08 01:34:52 +0100 |
| commit | 3a4f027ec05aa5fdf4098ceb0dab09f69c5e0b8b (patch) | |
| tree | 8a0c5bebff6a40e77bda8b02142d99a7c448545e /search/bin/poetaster | |
| parent | 340c3080b38518976c5c833399d8e07a7fc561bf (diff) | |
adding perl search index builder
Diffstat (limited to 'search/bin/poetaster')
| -rwxr-xr-x | search/bin/poetaster | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/search/bin/poetaster b/search/bin/poetaster new file mode 100755 index 0000000..fe973a5 --- /dev/null +++ b/search/bin/poetaster @@ -0,0 +1,33 @@ +#!/usr/bin/perl +use lib "../lib"; +use Rest; +use CGI; +use Poetaster; + +my $file = $ARGV[0] || "twain"; +my $data = load_data($file); +$data =~ s/<[^>]+>//g; +$data =~ s/\r\n/ /g; +$data =~ s/\s+/ /g; +$data =~ s/\. \. \. /... /g; +my $self = new Poetaster; +my $poem = $self->poem($data); +print $poem; + +sub load_data + { + my ($file) = @_; + my $data = ''; + if ($file =~ /^http/) + { + $data = Rest->new->rest_get_raw($file); + } + else + { + local $/; + open F, $file; + $data = <F>; + close F; + } + return $data; + } |
