From 3a4f027ec05aa5fdf4098ceb0dab09f69c5e0b8b Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 8 Dec 2017 01:34:52 +0100 Subject: adding perl search index builder --- search/bin/poetaster | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 search/bin/poetaster (limited to 'search/bin/poetaster') 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 = ; + close F; + } + return $data; + } -- cgit v1.2.3-70-g09d2