Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing bugs in quotes

  • Loading branch information...
commit ecc149c604679c3144dd9eb129fffc309bebca25 1 parent 32aa639
@rf rf authored
View
2  application/controllers/russtest.php
@@ -42,7 +42,7 @@ function index () {
$output['essay'] = $this->Quotes->run($entities, $parsely_articles, $inp);
- echo $output['essay'];
+ var_dump( $output['essay']);
}
function sentence () {
View
7 application/models/quotes.php
@@ -53,10 +53,11 @@ function run ($topics, $input_articles, $essay) {
foreach ($essay as $line_num => $line) {
foreach ($topics as $topic) {
+ if (!isset($quotes[$topic])) continue;
if (strstr($line, $topic) != NULL) {
- $rnd = rand(0, 2);
+ $rnd = rand(1, 1);
if ($rnd == 1) {
- $rnd_quote = rand(0, count($quotes[$topic]));
+ $rnd_quote = rand(0, count($quotes[$topic]) - 1);
array_splice($essay, $line_num, 0, $quotes[$topic][$rnd_quote]);
}
}
@@ -69,7 +70,7 @@ function run ($topics, $input_articles, $essay) {
function format ($author, $publication, $quote) {
$templates = array(
'As #{AUTHOR} of #{PUBLICATION} says, "#{QUOTE}"',
- 'Of course, "#{QUOTENOPERIOD}" as #{AUTHOR} of #{PUBLICATION} says.',
+ 'Of course, "#{QUOTENOPERIOD}" says #{AUTHOR} of #{PUBLICATION}.',
'#{AUTHOR} of #{PUBLICATION} states "#{QUOTE}"',
'#{AUTHOR} of #{PUBLICATION} says "#{QUOTE}"',
'As said by #{AUTHOR} of #{PUBLICATION}, "#{QUOTE}"',
Please sign in to comment.
Something went wrong with that request. Please try again.