This is a serializable class - which means that it can be serialized by the Yothalot framework, and transferred to other nodes in the Yothalot cluster. It is therefore possible that the map(), reduce() and write() methods will all be called on different nodes in the cluster. It is the responsibility of the Yothalot framework to make calls to your object at the right time. You are not supposed to make calls to methods of this class yourself.
상속: implements Yothalot\MapReduce
 public function testCountWordsWithNewLine()
 {
     $wc = new WordCount();
     $test_sentence = "My name is \n\r John";
     $wordcount = $wc->countWords($test_sentence);
     $this->assertEquals(4, $wordcount);
 }
 public function testCountWords()
 {
     $Wc = new WordCount();
     $TestSentence = "my name is afif";
     $WordCount = $Wc->countWords($TestSentence);
     $this->assertEquals(4, $WordCount);
 }
예제 #3
0
<?php

//get start
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
include "class/WordCount.php";
$str = file_get_contents("http://www.inedo.com/devops");
$counter = new WordCount($str);
print_r($counter->getSortedPhrases());
print_r($counter->getPhrasesWithWord('inedo'));
//include "class/HtmlParser.php";
//include "wrappers/HtmlHead.php";
//$str = file_get_contents("http://php.net/manual/en/function.preg-match.php");
//var_dump($str);
//$str = "<div id='test'>hello<div id='next'>world</div></div> ";
//$parser = new HtmlParser($str,'http://php.net/manual/en/function.preg-match.php');
//$head = new HtmlHead($parser);
//var_dump($parser->getFavicon());
//var_dump($head->getDoctype());
//var_dump($head->getEncoding());
//var_dump($parser->getTags('meta'));
//print_r($parser->getMeta());
//preg_match('@(?:\<title[\s+]?\>)@i',
//	"<title>hello mother</title> f****r", $matches);
//print_r($matches);
//include 'config.php';
//require_once "class/GoogleInfo.php";
//$url = "http://inedo.com";
//$stats =  new GoogleInfo($url);
예제 #4
0
    // or $modx->initialize('mgr');
    /* load the error handler */
    $modx->getService('error', 'error.modError', '', '');
    /* Set up logging */
    $modx->setLogLevel(xPDO::LOG_LEVEL_INFO);
    /* Check for CLI mode and set log target */
    if (php_sapi_name() == 'cli') {
        $cliMode = true;
        $modx->setLogTarget('ECHO');
    } else {
        $modx->setLogTarget('HTML');
    }
}
echo PHP_EOL;
require_once MODX_CORE_PATH . 'components/wordcount/model/wordcount/WordCount.php';
$wordCount = new WordCount();
$wordCount->init($modx);
echo 'With strip_tags()' . PHP_EOL;
$total = $wordCount->addResourceWhere(array('id:IN' => array(1, 2, 3, 4, 5, 30), 'OR:parent:IN' => array(1, 2, 3, 4, 5, 30)))->addResourceFilter('id:NOT IN', array(2672, 2673, 2674, 36, 1853, 2770, 2694, 1860, 2695, 2698))->countResources();
echo '  Estimated total word count for resources: ' . $total . ' from a page total of: ' . $wordCount->resourcePageTotal();
echo PHP_EOL;
echo '  Estimated total word count for Chunks: ' . $wordCount->countChunks();
echo PHP_EOL;
echo '  Estimated total word count for Lexicons: ' . $wordCount->countLexicons();
echo PHP_EOL;
echo '  Estimated total word count for Resource 1724 with strip tags: ' . $wordCount->setConfig('stripTags', true)->countResource(1724);
echo PHP_EOL;
echo 'Without strip_tags()' . PHP_EOL;
$wordCount->setConfig('stripTags', false);
$total = $wordCount->addResourceWhere(array('id:IN' => array(1, 2, 3, 4, 5, 30), 'OR:parent:IN' => array(1, 2, 3, 4, 5, 30)))->addResourceFilter('id:NOT IN', array(2672, 2673, 2674, 36, 1853, 2770, 2694, 1860, 2695, 2698))->countResources();
echo '  Estimated total word count for resources: ' . $total . ' from a page total of: ' . $wordCount->resourcePageTotal();