Example #1
0
<?php

include "rules.php";
include "libwiki.php";
$rule_hits = array();
$sentences = array();
$verbs = array();
define("MAX_RULES", 5);
$query = $_GET['entity'];
//search for the entity on wikipedia
$page = get_wiki_title($query);
$title = $page;
if (!$page) {
    echo "Can not find sufficient information on wikipedia";
    exit(1);
}
$page = str_replace(" ", "_", $page);
$page = "http://en.wikipedia.org/wiki/" . $page;
//$page="http://en.wikipedia.org/wiki/Mahatma_Gandhi";
/*$sentence="next sale is scheduled for oct 14, 2014";
$i=20;
process_sentence($sentence,$i);
exit();*/
$content = file_get_contents($page);
process_page($content);
//printf("max_rules=%d\n",MAX_RULES);
//Now process the rule_hits array
foreach ($rule_hits as $sentence_hits) {
    $event = array();
    foreach ($sentence_hits as $hit) {
        //print_r($hit);
Example #2
0
             file_put_contents("log/wolfduck.log", "{$to_log}\n", FILE_APPEND);
         }
     }
 }
 echo "<h3>DUCK result is : {$duck_retrurn}</h3>";
 if ($duck_retrurn) {
     $duck_retrurn = str_replace('<sup>', '^', $duck_retrurn);
     $duck_retrurn = trim(strip_tags($duck_retrurn));
 }
 if ($duck_retrurn) {
     if ($is_wolf) {
         $source = "wolf";
     } else {
         $source = "duck";
     }
     $wiki_sugg = get_wiki_title($spell_keywords);
     if ($wiki_sugg) {
         $suggestions[$sugg_index]['option'] = $options_list[] = "Article: {$wiki_sugg}";
         $suggestions[$sugg_index]['list'] = $list[] = array("content" => $wiki_sugg, "type" => "Also read");
         $sugg_index++;
     }
     if ($savetodata) {
         $query = "insert into data_new(query,source,source_id,suggestion) values('" . mysql_real_escape_string($spell_checked) . "','{$source}',{$machine_id},'" . mysql_real_escape_string(json_encode($suggestions)) . "')";
         mysql_query($query) or trigger_error(mysql_error() . " in {$query}", E_USER_ERROR);
         $id = mysql_insert_id();
         file_put_contents(DATA_PATH . "/{$source}/{$id}", $duck_retrurn);
         $current_file = "/{$source}/{$id}";
     } else {
         file_put_contents(DATA_PATH . "/temp/{$numbers}", $duck_retrurn);
         $current_file = "/temp/{$numbers}";
     }