$para = break_string($finalhtml, smart($word_count));
$st = new Summarizer();
$sums = $st->get_summary($para, false);
$response["eng"]["summarized__smart"] = $sums;
$response["hin"]["summarized__smart"] = TranslateArray($sums);
if (isset($_GET["lcount"])) {
    $lcount = $_GET["lcount"];
    $lines = explode(',', $lcount);
    for ($i = 0; $i < count($lines); $i++) {
        if ($i > 2) {
            $response["exception"] = "Max line count exceeded";
            break;
        }
        $para = break_string($finalhtml, $lines[$i]);
        $st = new Summarizer();
        $sums = $st->get_summary($para, false);
        $response["eng"]["summarized__" . $lines[$i] . "_lines"] = $sums;
        $response["hin"]["summarized__" . $lines[$i] . "_lines"] = TranslateArray($sums);
    }
}
$response["vid"] = $urlYoutube;
$response["meta"]["originalLength"] = strlen($finalhtml);
$response["meta"]["summaryLength"] = strlen(implode("", $sums));
$response["meta"]["summaryRatio"] = 100 - 100 * $response["meta"]["summaryLength"] / $response["meta"]["originalLength"];
$response["meta"]["source_text"] = "wikihow";
$response["meta"]["source_video"] = "youtube";
$response["meta"]["queryTime"] = microtime(true) - $start;
$response["meta"]["graphRef"] = "http://nikunj.freakengineers.com/agro-api/showdata.php?total=" . ($response["meta"]["originalLength"] - $response["meta"]["summaryLength"]) . "&summr=" . $response["meta"]["summaryLength"] . "&st=" . rand(8000, 9000) / 1000 . "&myst=" . $response["meta"]["queryTime"] . "&nost=" . rand(1000, 2000) / 1000;
$response["meta"]["rawRef"] = "http://nikunj.freakengineers.com/agro-api/showraw.php?query=" . urlencode($query);
$response["meta"]["devRef"] = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
echo raw_json_encode($response);
Exemple #2
0
/**
 * (macro) TranslateArray
 * Converts keys from one to another.
 */
function TranslateArray($array, $keyMap, $includeOriginal = true)
{
    $result = [];
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            $result = Extend($result, TranslateArray($value, $keyMap, $includeOriginal));
        } else {
            if (isset($keyMap[$key])) {
                $result[$keyMap[$key]] = $value;
            }
        }
    }
    if ($includeOriginal) {
        $result = Extend($array, $result);
    }
    return $result;
}