-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.pl
More file actions
49 lines (39 loc) · 1011 Bytes
/
main.pl
File metadata and controls
49 lines (39 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
require "./perlbot.pl";
my $blog = WWW::Tumblr::Blog->new(
'consumer_key' => $ENV{OAUTH_CONSUMER_KEY},
'secret_key' => $ENV{OAUTH_CONSUMER_SECRET},
'token' => $ENV{OAUTH_TOKEN},
'token_secret' => $ENV{OAUTH_TOKEN_SECRET},
'base_hostname' => 'perlbot.tumblr.com',
);
die Dumper($blog->error) unless $blog->info();
my $markov = String::Markov->new(
order => 2,
sep => '',
split_sep => ' ',
join_sep => ' ',
null => "\0",
stable => 1,
normalize => 'C',
do_chomp => 1,
);
my @files = (
"show_dialogue.txt",
"blog_dialogue.txt",
);
my @dialogue = ();
foreach (@files) {
open FILE, $_ or die "couldn't open '$_': $!";
binmode(FILE, ":utf8");
push(@dialogue, <FILE>);
close FILE;
}
foreach (@dialogue) { $markov->add_sample($_) }
my %forbidden_sentences;
$forbidden_sentences{$_} = 1 for @dialogue;
for (0..1) {
my $sentence = generate_sentence($markov, \%forbidden_sentences);
queue_post($blog, $sentence);
}
answer_asks($blog);