示例#1
0
 public function testMaxWords()
 {
     $this->assertEquals('Taylor...', TextLib::maxWords('Taylor Otwell', 1));
     $this->assertEquals('Taylor___', TextLib::maxWords('Taylor Otwell', 1, ['ellipsis' => '___']));
     $this->assertEquals('Taylor Otwell', TextLib::maxWords('Taylor Otwell', 3));
 }
 protected function _analyze($text, $type = null)
 {
     $res = array();
     if (empty($text)) {
         return $res;
     }
     App::uses('TextLib', 'Tools.Utility');
     $textLib = new TextLib($text);
     ini_set('memory_limit', '128M');
     $res['words'] = $textLib->wordCount($this->request->data['Form']);
     $res['sentence_count'] = $textLib->getSentence();
     $res['paragraph_count'] = $textLib->getParagraph();
     $res['length'] = $textLib->getLength();
     $res['is_ascii'] = $textLib->isAscii();
     $res['word_count'] = $textLib->getWord();
     return $res;
 }