示例#1
0
<?php

include "summarizer.class.php";
ob_start();
?>
Lean emerged out of the manufacturing world with a rallying cry for Òwaste reductionÓ in the production process. Lean Software drew parallels between hardware and software manufacturing processes and aimed to reduce waste also in the production process.


Then Lean Startup came along and pointed out that efficient production is NOT enough UNLESS it also delivers customer value and emphasized learning OVER production towards that end.
In a startup (or any new product) where you don't yet know whether what you produce will generate customer value, you are better served by limiting or completely forgoing production (through an MVP or concierge MVP, for example) to first test value creation.

You have to first find a problem worth solving before committing resources to build and scale a solution. This is the essence of what I teach in my bootcamps where I have a "no code rule" and teach how to forgo such production completely until the right time. That said, while I've always found this logic highly rational, it's often a hard pill to swallow for entrepreneurs because we love production and optimization of production processes.
I also couldn't help feeling that the full impact of all that lean thinking has to offer is left deferred to latter stages when customer value production is in full tilt (after Product/Market Fit).


Then I had an mini-epiphany.
<?php 
$content = ob_get_contents();
ob_end_clean();
$st = new Summarizer();
$summary = $st->get_summary($content);
echo $summary;
var_dump($st->how_we_did());
$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);
    echo json_encode($response);
    die("");
}
$response["status"] = "OK";
$response["author"] = "Nikunj Sharma";
$query = $_GET["query"];
$url = getUrl($query);
$urlYoutube = getUrlYoutube($query);
$html = file_get_html($url);
$vartemp;
foreach ($html->find('ol.steps_list_2 li') as $element) {
    $element->find(".step_num", 0)->innertext = '';
    $vartemp .= $element->outertext . " ";
}
$finalhtml = html2text($vartemp);
$finalhtml = preg_replace('/\\s+/', ' ', $finalhtml);
$finalhtml = preg_replace('/\\[.*?\\]/', '', $finalhtml);
$response["original"] = $finalhtml;
$word_count = str_word_count($finalhtml);
function smart($word_count)
{
    if ($word_count <= 1200) {
        return 4;
    } else {
        return 6;
    }
}
$para = break_string($finalhtml, smart($word_count));
$st = new Summarizer();
$sums = $st->get_summary($para, true);