public function save($con = null) { $highlighted = myUtils::highlight($this->getRawBody()); $this->setBody($highlighted['body']); $summarizer = new Summarizer(200); $this->setSummary($summarizer->summarize($this->getBody())); parent::save(); }
public function save($con = null) { $highlighted = myUtils::highlight($this->getRawBody()); $this->setBody($highlighted['body']); foreach ($this->getSnippetLanguages() as $language) { $language->delete(); } foreach ($highlighted['langs'] as $lang => $count) { $sl = new SnippetLanguage(); $sl->setName($lang); $sl->setSnippet($this); $this->addSnippetLanguage($sl); } $summarizer = new Summarizer(400); $this->setSummary($summarizer->summarize($this->getBody())); parent::save(); }
if (!ctype_xdigit($json_decoded['uuid'])) { header('Status: 400 Bad Request'); error_log('UUID is not valid'); exit(2); } // Check for time deviation larger 1 minute if (abs(strtotime($json_decoded['lastupdated']) - time()) > 90) { header('Status: 400 Bad Request'); error_log('Node date deviation too large'); exit(2); } // Overwrite lastupdated with servers time to make timestamps comparable $json_decoded['lastupdated'] = time(); // Store JSON file_put_contents($data_dir . '/' . preg_replace('/[^\\da-z]/i', '', substr($json_decoded['uuid'], 0, 30)) . '.json', $json); $summarizer = new Summarizer(); // Clean up old files and sum up results foreach (glob($data_dir . '/*') as $file) { if (basename($file) == 'merged.json' || basename($file) == 'overall.json') { continue; } if (filemtime($file) < strtotime('-8 hours')) { unlink($file); continue; } $json = json_decode(file_get_contents($file)); $json_merged[] = $json; $summarizer->addMonitorResults($json); } file_put_contents($data_dir . '/merged.json', json_encode($json_merged)); $overall_state = $summarizer->getSummary();
} $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']}";
<?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());
<?php /** * @author W-Shadow * @url http://w-shadow.com/ * @copyright 2008 */ error_reporting(E_ALL); require_once 'includes/summarizer.php'; require_once 'includes/html_functions.php'; $summarizer = new Summarizer(); if (!empty($_POST['text'])) { //echo '<pre>'; $text = $_POST['text']; //replace some Unicode characters with ASCII $text = normalizeHtml($text); //generate the summary with default parameters $rez = $summarizer->summary($text); //print_r($rez); //$rez is an array of sentences. Turn it into contiguous text by using implode(). $summary = implode(' ', $rez); //echo '</pre>'; } ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <div align='center'> <form method='POST' action='test_summarizer.php'> <h3>Text Summarizer</h3> <textarea name='text' cols='50' rows='10'><?php echo !empty($_POST['text']) ? htmlspecialchars($_POST['text']) : ''; ?>
$response["status"] = "missing query"; 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);