예제 #1
0
파일: ChunkTest.php 프로젝트: vend/chunky
 public function testNormalContract()
 {
     $chunk = new Chunk(100, 1);
     $chunk->begin();
     $chunk->end(10);
     $this->assertInternalType('int', $chunk->getEstimatedSize());
 }
예제 #2
0
파일: Parser.php 프로젝트: scrobot/Lumen
 /**
  * @param Diff $diff
  * @param array $lines
  */
 private function parseFileDiff(Diff $diff, array $lines)
 {
     $chunks = array();
     foreach ($lines as $line) {
         if (preg_match('/^@@\\s+-(?P<start>\\d+)(?:,\\s*(?P<startrange>\\d+))?\\s+\\+(?P<end>\\d+)(?:,\\s*(?P<endrange>\\d+))?\\s+@@/', $line, $match)) {
             $chunk = new Chunk($match['start'], isset($match['startrange']) ? max(1, $match['startrange']) : 1, $match['end'], isset($match['endrange']) ? max(1, $match['endrange']) : 1);
             $chunks[] = $chunk;
             $diffLines = array();
             continue;
         }
         if (preg_match('/^(?P<type>[+ -])?(?P<line>.*)/', $line, $match)) {
             $type = Line::UNCHANGED;
             if ($match['type'] == '+') {
                 $type = Line::ADDED;
             } elseif ($match['type'] == '-') {
                 $type = Line::REMOVED;
             }
             $diffLines[] = new Line($type, $match['line']);
             if (isset($chunk)) {
                 $chunk->setLines($diffLines);
             }
         }
     }
     $diff->setChunks($chunks);
 }
예제 #3
0
 public function close()
 {
     if (!$this->closed) {
         $this->closed = true;
         unset($this->level->updateTiles[$this->id]);
         if ($this->chunk instanceof FullChunk) {
             $this->chunk->removeTile($this);
         }
         if (($level = $this->getLevel()) instanceof Level) {
             $level->removeTile($this);
         }
         $this->level = null;
     }
 }
예제 #4
0
 static function checkNegaPosi($from, $to)
 {
     if ($from === "" || $to === "") {
         return false;
     }
     $chunks = Chunk::all();
     $result = null;
     foreach ($chunks as $chunk) {
         $_from = $chunk['from'];
         $_to = $chunk['to'];
         if (preg_match("/{$_from}/u", $from) && preg_match("/{$_to}/u", $to)) {
             $result = trim($chunk['nega_posi']);
             break;
         }
     }
     if ($result == null || $result == "non") {
         $result = "f";
     }
     return $result;
 }
예제 #5
0
 /**
  * @param Diff  $diff
  * @param array $lines
  */
 private function parseFileDiff(Diff $diff, array $lines)
 {
     $chunks = array();
     while (count($lines)) {
         while (!preg_match('(^@@\\s+-(?P<start>\\d+)(?:,\\s*(?P<startrange>\\d+))?\\s+\\+(?P<end>\\d+)(?:,\\s*(?P<endrange>\\d+))?\\s+@@)', $last = array_shift($lines), $match)) {
             if ($last === null) {
                 break 2;
             }
         }
         $chunk = new Chunk($match['start'], isset($match['startrange']) ? max(1, $match['startrange']) : 1, $match['end'], isset($match['endrange']) ? max(1, $match['endrange']) : 1);
         $diffLines = array();
         $last = null;
         while (count($lines) && (preg_match('(^(?P<type>[+ -])?(?P<line>.*))', $last = array_shift($lines), $match) || strpos($last, '\\ No newline at end of file') === 0)) {
             if (count($match)) {
                 $type = Line::UNCHANGED;
                 if ($match['type'] == '+') {
                     $type = Line::ADDED;
                 } elseif ($match['type'] == '-') {
                     $type = Line::REMOVED;
                 }
                 $diffLines[] = new Line($type, $match['line']);
             }
         }
         $chunk->setLines($diffLines);
         $chunks[] = $chunk;
         if ($last !== null) {
             array_unshift($lines, $last);
         }
     }
     $diff->setChunks($chunks);
 }
예제 #6
0
파일: index.php 프로젝트: boomcms/boom-core
        ?>
">
                                        <h3><?php 
        echo $p->getTitle();
        ?>
</h3>
                                        <time datetime="<?php 
        echo $p->getVisibleFrom()->format('d M Y H:i');
        ?>
"></time>
                                        <p><?php 
        echo $p->url();
        ?>
</p>
                                        <p><?php 
        echo Chunk::get('text', 'standfirst', $p)->text();
        ?>
</p>
                                    </a>
                                </li>
                            </ol>
                        <?php 
    } else {
        ?>
                            <p><?php 
        echo trans('boomcms::dashboard.approvals.none');
        ?>
</p>
                        <?php 
    }
    ?>
예제 #7
0
 /**
  * @param string $data
  */
 public function __construct($data)
 {
     parent::__construct('VP8X', $data);
     var_dump($this->hasXmp());
     var_dump($this->hasExif());
 }
</div>
</div>
</div>
<div class="swiper-slide riddle">
<div class="slide_content">
<div class="question">
<h5>Riddle #1</h5>
<h3>I become whiter while going dirtier. What am I?</h3>
<a class="btn green_btn reveal_answer_btn">reveal answer</a>
</div>
<div class="answer">
<div id="chalk_container">
<img src="<?php 
echo Site::url();
?>
/public/assets/img/welcome/chalkboard.png" alt="" id="chalk_bg"/>
<?php 
Chunk::get('chalk-answer');
?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="swiper-button-prev"><i class='glyphicon glyphicon-chevron-left'></i></div>
<div class="swiper-button-next"><i class='glyphicon glyphicon-chevron-right'></i></div>
</div>
</div>
</div>
</div>
예제 #9
0
 public function getIndex()
 {
     // 酒のレビューを取得。現在はサンプルのレビューを使用。
     $reviews = Review::where('item_id', 41)->take(4)->get();
     $last_result = array();
     /*-----------------------------------------
      * 形態素解析, 係受け構文解析
      *---------------------------------------*/
     foreach ($reviews as $review) {
         $params = array('type' => 'chunk', 'text' => $review->content);
         $yahoo_result = YahooApi::fetch($params);
         if ($yahoo_result === false) {
             continue;
         }
         $last_result = Chunk::getChunks($yahoo_result, $review->content, $review, $last_result, $review->is_bought);
     }
     /*-----------------------------------------
      * 類義語検索
      *---------------------------------------*/
     foreach ($last_result as $key => $value) {
         $s = explode(',', $value['info']);
         // 名詞が形容詞にかかっている場合
         if (preg_match('/.*?(名詞)/u', $s[2]) && preg_match('/.*?(形容|動詞)/u', $s[6])) {
             $adje = explode('-', $s[6]);
             // 品詞
             $pos = explode('-', $s[5]);
             // 単語
             $_adje = explode('-', $s[2]);
             // 品詞
             $_pos = explode('-', $s[1]);
             // 単語
             // for ($i = 0; $i < count($_adje); $i++) {
             //     $syno = null;
             //     if (preg_match('/.*?(名詞)/u', $_adje[$i]) && count($_adje) > 1) {
             //         if ($_adje[0] == '名詞' && $_adje[1] == '助動詞') {
             //             $syno = Thesaurus::checkThesaurus($_pos[$i]);
             //             $_ll_result = array();
             //             if ($syno) {
             //                 $_ll_result['text'] = $syno['text'];
             //                 $_ll_result['rayer'] = $syno['rayer'];
             //                 $_ll_result['info'] = $value['info'];
             //                 $ll_result[trim($syno['text'])][] = $_ll_result;
             //             }
             //         }
             //     }
             // }
             for ($i = 0; $i < count($adje); $i++) {
                 $syno = null;
                 if (preg_match('/^(形容|動詞)/u', $adje[$i], $match)) {
                     // 形容詞が含まれていれば
                     if ($match[0] == '形容') {
                         $syno = Thesaurus::checkThesaurus($pos[$i]);
                         if ($syno && $syno->text == '無い') {
                             for ($j = 0; $j < count($_adje); $j++) {
                                 if ($_adje[$j] == '名詞') {
                                     $syno = Thesaurus::checkThesaurus($_pos[$i]);
                                 }
                             }
                         }
                     } else {
                         if ($match[0] == '動詞') {
                             $_syno = Thesaurus::checkThesaurus($pos[$i]);
                             if ($_syno && isset($pos[1])) {
                                 if (in_array($pos[0] . $pos[1], explode(',', $_syno->synonym))) {
                                     $syno = $_syno;
                                 }
                             }
                         }
                     }
                     if (!isset($syno)) {
                         break;
                     }
                     $_ll_result = array();
                     // もし同じような形容詞があれば1つにまとめていく
                     if ($syno) {
                         $_ll_result['text'] = $syno['text'];
                         $_ll_result['rayer'] = $syno['rayer'];
                         $_ll_result['info'] = $value['info'];
                         $ll_result[trim($syno['text'])][] = $_ll_result;
                     }
                 }
             }
         } else {
             if (preg_match('/.*?(副詞)/u', $s[2]) && preg_match('/.*?(名詞)/u', $s[6])) {
                 $adje = explode('-', $s[6]);
                 // 品詞
                 $pos = explode('-', $s[5]);
                 // 単語
                 $_adje = explode('-', $s[2]);
                 // 品詞
                 $_pos = explode('-', $s[1]);
                 // 単語
                 for ($i = 0; $i < count($adje); $i++) {
                     $syno = null;
                     if (preg_match('/.*?(名詞)/u', $adje[$i])) {
                         $syno = Thesaurus::checkThesaurus($pos[$i]);
                         $_ll_result = array();
                         if ($syno) {
                             $_ll_result['text'] = $syno['text'];
                             $_ll_result['rayer'] = $syno['rayer'];
                             $_ll_result['info'] = $value['info'];
                             $ll_result[trim($syno['text'])][] = $_ll_result;
                         }
                     }
                 }
             }
         }
     }
     echo '<pre>';
     var_dump($ll_result);
     echo '</pre>';
 }
예제 #10
0
파일: chunk.php 프로젝트: anteknik/arsip
<?php

require 'config.php';
session_name($_CONFIG["session_name"]);
session_start();
require 'users.php';
require 'class.php';
$timeconfig = $_CONFIG['default_timezone'];
$timezone = strlen($timeconfig) > 0 ? $timeconfig : "UTC";
date_default_timezone_set($timezone);
$chunk = new Chunk();
$encodeExplorer = new EncodeExplorer();
if (isset($_SESSION['lang'])) {
    $lang = $_SESSION['lang'];
} else {
    $lang = SetUp::getConfig("lang");
}
require "translations/" . $lang . ".php";
$gateKeeper = new GateKeeper();
if ($gateKeeper->isAccessAllowed() && $gateKeeper->isAllowed('upload_enable')) {
    if ($_SERVER['REQUEST_METHOD'] === 'GET') {
        if ($_GET['resumableChunkNumber'] == 1) {
            $firstChunk = true;
        } else {
            $firstChunk = false;
        }
        $resumabledata = $chunk->setupFilename($_GET['resumableFilename'], $_GET['resumableIdentifier']);
        $resumableFilename = $resumabledata['filename'];
        $extension = $resumabledata['extension'];
        $basename = $resumabledata['basename'];
        $fullfilepath = $_GET['loc'] . $resumableFilename;
예제 #11
0
 protected function unserializeChunk($data)
 {
     return Chunk::fromBinary($data, $this->levelProvider);
 }
예제 #12
0
 /**
  * Queries and returns archive data using a set of archive IDs.
  *
  * @param array $archiveIds The IDs of the archives to get data from.
  * @param array $recordNames The names of the data to retrieve (ie, nb_visits, nb_actions, etc.)
  * @param string $archiveDataType The archive data type (either, 'blob' or 'numeric').
  * @param int|null|string $idSubtable  null if the root blob should be loaded, an integer if a subtable should be
  *                                     loaded and 'all' if all subtables should be loaded.
  * @throws Exception
  * @return array
  */
 public function getArchiveData($archiveIds, $recordNames, $archiveDataType, $idSubtable)
 {
     $chunk = new Chunk();
     // create the SQL to select archive data
     $loadAllSubtables = $idSubtable == Archive::ID_SUBTABLE_LOAD_ALL_SUBTABLES;
     if ($loadAllSubtables) {
         $name = reset($recordNames);
         // select blobs w/ name like "$name_[0-9]+" w/o using RLIKE
         $nameEnd = strlen($name) + 1;
         $nameEndAppendix = $nameEnd + 1;
         $appendix = $chunk->getAppendix();
         $lenAppendix = strlen($appendix);
         $checkForChunkBlob = "SUBSTRING(name FROM {$nameEnd} FOR {$lenAppendix}) = '{$appendix}'";
         $checkForSubtableId = "(SUBSTRING(name FROM {$nameEndAppendix} FOR 1) >= '0'\n                                    AND SUBSTRING(name FROM {$nameEndAppendix} FOR 1) <= '9')";
         $whereNameIs = "(name = ? OR (name LIKE ? AND ( {$checkForChunkBlob} OR {$checkForSubtableId} ) ))";
         $bind = array($name, $name . '%');
     } else {
         if ($idSubtable === null) {
             // select root table or specific record names
             $bind = array_values($recordNames);
         } else {
             // select a subtable id
             $bind = array();
             foreach ($recordNames as $recordName) {
                 // to be backwards compatibe we need to look for the exact idSubtable blob and for the chunk
                 // that stores the subtables (a chunk stores many blobs in one blob)
                 $bind[] = $chunk->getRecordNameForTableId($recordName, $idSubtable);
                 $bind[] = ArchiveSelector::appendIdSubtable($recordName, $idSubtable);
             }
         }
         $inNames = Common::getSqlStringFieldsArray($bind);
         $whereNameIs = "name IN ({$inNames})";
     }
     $getValuesSql = "SELECT %s, name, idsite, date1, date2, ts_archived\n                         FROM %s\n                         WHERE idarchive IN (%s)\n                           AND " . $whereNameIs;
     // get data from every table we're querying
     $rows = array();
     foreach ($archiveIds as $period => $ids) {
         if (empty($ids)) {
             throw new Exception("Unexpected: id archive not found for period '{$period}' '");
         }
         // $period = "2009-01-04,2009-01-04",
         $date = Date::factory(substr($period, 0, 10));
         $isNumeric = $archiveDataType == 'numeric';
         if ($isNumeric) {
             $table = ArchiveTableCreator::getNumericTable($date);
         } else {
             $table = ArchiveTableCreator::getBlobTable($date);
         }
         $valueCol = $this->prepareForBinary($table);
         $sql = sprintf($getValuesSql, $valueCol, $table, implode(',', $ids));
         $dataRows = $this->db->fetchAll($sql, $bind);
         $dataRows = $this->binaryOutput($dataRows, true);
         foreach ($dataRows as $row) {
             if ($isNumeric) {
                 $rows[] = $row;
             } else {
                 $row['value'] = $this->uncompress($row['value']);
                 if ($chunk->isRecordNameAChunk($row['name'])) {
                     $this->moveChunkRowToRows($rows, $row, $chunk, $loadAllSubtables, $idSubtable);
                 } else {
                     $rows[] = $row;
                 }
             }
         }
     }
     return $rows;
 }
예제 #13
0
    <footer class="container">    	
            <div class="pull-left"><?php 
echo Chunk::get('footer-links');
?>
</div>
            <div class="pull-right"><?php 
Action::run('theme_footer');
echo Site::powered();
?>
</div>
    </footer>
    <?php 
echo Snippet::get('google-analytics');
?>
    
  </body>
</html>
 /**
  * Exports designer project
  */
 public function export($info)
 {
     $chunk = new Chunk();
     if (!$chunk->save($info)) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
         return array();
     }
     if ($chunk->last()) {
         ProviderLog::start('export');
         ProviderLog::start('export:json_decode');
         $content = json_decode($chunk->complete(), true);
         ProviderLog::end('export:json_decode');
         $this->_exportTheme($content);
         ProviderLog::end('export');
         return array('result' => 'done', 'log' => ProviderLog::getLog());
     }
     return array('result' => 'processed');
 }
 public function ajaxProcessFsoZip()
 {
     try {
         $chunk = new Chunk();
         if (!$chunk->save($this->_getChunkInfo())) {
             header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
             return array();
         }
         if (!$chunk->last()) {
             return array('result' => 'processed');
         }
         $data = json_decode($chunk->complete(), true);
         if (!isset($data['fso'])) {
             throw new Exception('Empty fso');
         }
         $designer = $this->getDesignerObj();
         $response = $designer->zipFso($data);
         die(Tools::jsonEncode($response));
     } catch (PermissionsException $e) {
         die($this->_exceptionResponse($e));
     }
 }
<div class="col-xs-12">
<?php 
Action::run('theme_pre_content');
?>
</div>
</div><div class="row">
<div class="col-xs-12">
<div class="monstra-blog-post">
<?php 
echo Blog::getPost();
?>
</div>
<small class="monstra-blog-date"><?php 
echo Blog::getPostDate('d M Y');
?>
 / <?php 
echo Blog::getPostAuthor();
?>
</small>
</div>
</div><div class="row">
<div class="col-xs-12">
<?php 
Action::run('theme_post_content');
?>
</div>
</div></div>
</div>
<?php 
Chunk::get('footer');
예제 #17
0
 public function make()
 {
     $params = Input::all();
     $id = $params['item-id'];
     // 決定表作成時はmax_execution_timeの制限を外す
     set_time_limit(3000);
     // TODO: ファイル作成する部分。ファイル以外で実現したい
     //$file_name = 'drh.dat';
     $file_name = $id . '.dat';
     $fp = fopen('assets/dat/' . $file_name, 'w');
     // 酒のレビューを取得。現在はサンプルのレビューを使用。
     $reviews = Review::where('item_id', $id)->get();
     $last_result = array();
     /*-----------------------------------------
      * 形態素解析, 係受け構文解析
      *---------------------------------------*/
     foreach ($reviews as $review) {
         $params = array('type' => 'chunk', 'text' => $review->content);
         $yahoo_result = YahooApi::fetch($params);
         if ($yahoo_result === false) {
             continue;
         }
         $last_result = Chunk::getChunks($yahoo_result, $review->content, $review, $last_result, $review->is_bought);
     }
     /*-----------------------------------------
      * 類義語検索
      *---------------------------------------*/
     foreach ($last_result as $key => $value) {
         $s = explode(',', $value['info']);
         // 名詞が形容詞にかかっている場合
         if (preg_match('/.*?(名詞)/u', $s[2]) && preg_match('/.*?(形容|動詞)/u', $s[6])) {
             $adje = explode('-', $s[6]);
             // 品詞
             $pos = explode('-', $s[5]);
             // 単語
             $_adje = explode('-', $s[2]);
             // 品詞
             $_pos = explode('-', $s[1]);
             // 単語
             for ($i = 0; $i < count($_adje); $i++) {
                 $syno = null;
                 if (preg_match('/.*?(名詞)/u', $_adje[$i]) && count($_adje) > 1) {
                     if ($_adje[0] == '名詞' && $_adje[1] == '助動詞') {
                         $syno = Thesaurus::checkThesaurus($_pos[$i]);
                     }
                     $_ll_result = array();
                     if ($syno) {
                         $_ll_result['text'] = $syno['text'];
                         $_ll_result['rayer'] = $syno['rayer'];
                         $_ll_result['info'] = $value['info'];
                         $ll_result[trim($syno['text'])][] = $_ll_result;
                     }
                 }
             }
             for ($i = 0; $i < count($adje); $i++) {
                 $syno = null;
                 if (preg_match('/^(形容|動詞)/u', $adje[$i], $match)) {
                     // 形容詞が含まれていれば
                     if ($match[0] == '形容') {
                         $syno = Thesaurus::checkThesaurus($pos[$i]);
                         if ($syno && $syno->text == '無い') {
                             for ($j = 0; $j < count($_adje); $j++) {
                                 if ($_adje[$j] == '名詞') {
                                     $syno = Thesaurus::checkThesaurus($_pos[$i]);
                                 }
                             }
                         }
                     } else {
                         if ($match[0] == '動詞') {
                             $_syno = Thesaurus::checkThesaurus($pos[$i]);
                             if ($_syno && isset($pos[1])) {
                                 if (in_array($pos[0] . $pos[1], explode(',', $_syno->synonym))) {
                                     $syno = $_syno;
                                 }
                             }
                         }
                     }
                     if (!isset($syno)) {
                         break;
                     }
                     $_ll_result = array();
                     // もし同じような形容詞があれば1つにまとめていく
                     if ($syno) {
                         $_ll_result['text'] = $syno['text'];
                         $_ll_result['rayer'] = $syno['rayer'];
                         $_ll_result['info'] = $value['info'];
                         $ll_result[trim($syno['text'])][] = $_ll_result;
                     }
                 }
             }
             // for ($i = 0; $i < count($adje); $i++) {
             //     if (preg_match('/.*?(形容)/u', $adje[$i], $match)) { // 形容詞が含まれていれば
             //         $syno = Thesaurus::checkThesaurus($pos[$i]);
             //         $_ll_result = array();
             //         // もし同じような形容詞があれば1つにまとめていく
             //         if ($syno) {
             //             $_ll_result['text']  = $syno['text'];
             //             $_ll_result['rayer'] = $syno['rayer'];
             //             $_ll_result['info']  = $value['info'];
             //             $ll_result[trim($syno['text'])][] = $_ll_result;
             //         }
             //     }
             // }
         } else {
             if (preg_match('/.*?(副詞)/u', $s[2]) && preg_match('/.*?(名詞)/u', $s[6])) {
                 $adje = explode('-', $s[6]);
                 // 品詞
                 $pos = explode('-', $s[5]);
                 // 単語
                 $_adje = explode('-', $s[2]);
                 // 品詞
                 $_pos = explode('-', $s[1]);
                 // 単語
                 for ($i = 0; $i < count($adje); $i++) {
                     $syno = null;
                     if (preg_match('/.*?(名詞)/u', $adje[$i])) {
                         $syno = Thesaurus::checkThesaurus($pos[$i]);
                         $_ll_result = array();
                         if ($syno) {
                             $_ll_result['text'] = $syno['text'];
                             $_ll_result['rayer'] = $syno['rayer'];
                             $_ll_result['info'] = $value['info'];
                             $ll_result[trim($syno['text'])][] = $_ll_result;
                         }
                     }
                 }
             }
         }
     }
     // foreach ($last_result as $key => $value) {
     //     $s = explode(',', $value['info']);
     //     // 名詞が形容詞にかかっている場合
     //     if (preg_match('/.*?(名詞)/u', $s[2]) && preg_match('/.*?(形容)/u', $s[6])) {
     //         $adje = explode('-', $s[6]); // 品詞
     //         $pos = explode('-', $s[5]);  // 単語
     //         $_adje = explode('-', $s[2]); // 品詞
     //         $_pos = explode('-', $s[1]); // 単語
     //         for ($i = 0; $i < count($_adje); $i++) {
     //             if (preg_match('/.*?(名詞)/u', $_adje[$i])) {
     //                 $syno = Thesaurus::checkThesaurus($_pos[$i]);
     //                 $_ll_result = array();
     //                 if ($syno) {
     //                     $_ll_result['text'] = $syno['text'];
     //                     $_ll_result['rayer'] = $syno['rayer'];
     //                     $_ll_result['info'] = $value['info'];
     //                     $ll_result[trim($syno['text'])][] = $_ll_result;
     //                 }
     //             }
     //         }
     //         for ($i = 0; $i < count($adje); $i++) {
     //             if (preg_match('/.*?(形容)/u', $adje[$i])) { // 形容詞が含まれていれば
     //                 $syno = Thesaurus::checkThesaurus($pos[$i]);
     //                 $_ll_result = array();
     //                 // もし同じような形容詞があれば1つにまとめていく
     //                 if ($syno) {
     //                     $_ll_result['text']  = $syno['text'];
     //                     $_ll_result['rayer'] = $syno['rayer'];
     //                     $_ll_result['info']  = $value['info'];
     //                     $ll_result[trim($syno['text'])][] = $_ll_result;
     //                 }
     //             }
     //         }
     //     }
     // }
     /*-----------------------------------------
      * 感性ワードの出現率を検索する
      *---------------------------------------*/
     $all_review_count = $this->review_gestion->where('item_id', '=', $id)->count();
     // 全レビュー件数
     foreach ($ll_result as $key => $value) {
         $review_count = count($ll_result[$key]);
         $review_percents[$key] = $review_count / $all_review_count;
     }
     //        $all_review_count = 0; // 採用したレビュー件数
     //        foreach ($ll_result as $key => $value) {
     //            $review_counts[$key] = count($ll_result[$key]);
     //            $all_review_count += count($ll_result[$key]);
     //        }
     //        foreach ($review_counts as $key => $review_count) {
     //            $review_percents[$key] = $review_count/$all_review_count;
     //        }
     // 形を整える
     foreach ($review_percents as $key => $review_percent) {
         $review_percents[$key] = substr($review_percent * 100, 0, 4);
     }
     /*-----------------------------------------
      * 決定表を作成する
      *---------------------------------------*/
     $drh = Dr::getDRH($ll_result);
     /*-----------------------------------------
      * 属性値を出力する
      *---------------------------------------*/
     //属性値を出力する
     echo "#ATTRS" . PHP_EOL;
     fwrite($fp, "#ATTRS" . PHP_EOL);
     // TODO: ファイルへの書き込み
     foreach ($drh['attrs'] as $key => $val) {
         fwrite($fp, $key . " " . $val . PHP_EOL);
         // TODO: ファイルへ書き込み
         echo $key . " " . $val . PHP_EOL;
     }
     fwrite($fp, PHP_EOL);
     // TODO: ファイルへ書き込み
     echo PHP_EOL;
     /*-----------------------------------------
      * 付加情報の出力
      *---------------------------------------*/
     $si = 1;
     echo "#INFOATTRS" . PHP_EOL;
     fwrite($fp, "#INFOATTRS" . PHP_EOL);
     // TODO: ファイルへ書き込み
     foreach ($drh['drh'] as $key => $val) {
         echo $si . " " . $key;
         fwrite($fp, $si . " " . $key);
         // TODO: ファイルへ書き込み
         foreach ($val as $k => $v) {
             if ($k == 'drc') {
                 echo " " . $v;
                 fwrite($fp, " " . $v);
                 // TODO: ファイルへ書き込み
             } else {
                 if (isset($v['text'])) {
                     echo " " . $k . ":" . implode(',', $v['text']);
                     fwrite($fp, " " . $k . ":" . implode(',', $v['text']));
                     // TODO: ファイルへ書き込み
                 } else {
                     echo " " . "*";
                     fwrite($fp, " " . "*");
                     // TODO: ファイルへ書き込み
                 }
             }
         }
         echo PHP_EOL;
         fwrite($fp, PHP_EOL);
         // TODO: ファイルへ書き込み
         $si++;
     }
     echo PHP_EOL;
     /*-----------------------------------------
      * 決定表の出力
      *---------------------------------------*/
     echo "#DRH" . PHP_EOL;
     fwrite($fp, "#DRH" . PHP_EOL);
     // TODO: ファイルへ書き込み
     $si = 1;
     foreach ($drh['drh'] as $key => $val) {
         echo $si;
         fwrite($fp, $si);
         // TODO: ファイルへ書き込み
         $_sample = array();
         foreach ($val as $k => $v) {
             if ($k == 'drc') {
                 echo " " . $v;
                 fwrite($fp, " " . $v);
                 // TODO: ファイルへ書き込み
                 $dc[] = $v;
             } else {
                 echo " " . $k . $v['atr'];
                 fwrite($fp, " " . $k . $v['atr']);
                 // TODO: ファイルへ書き込み
                 $_sample[] = $k . $v['atr'];
             }
         }
         $sample[] = $_sample;
         echo PHP_EOL;
         fwrite($fp, PHP_EOL);
         // TODO: ファイルへ書き込み
         $si++;
     }
     echo PHP_EOL;
     fwrite($fp, PHP_EOL);
     // TODO: ファイルへ書き込み
     /*-----------------------------------------
      * 決定ルールの算出
      *---------------------------------------*/
     $MODE = "un_appro";
     //un_appro:下近似, up_appro:上近似
     Dr::setData($sample, $dc);
     /*(下/上)近似を求める//--------------------------------*/
     $appro = array();
     switch ($MODE) {
         case "un_appro":
             $appro = Dr::calUNAppro();
             break;
         case "up_appro":
             break;
     }
     /*//下近似を求める-------------------------------------*/
     /*-----------------------------------------
      * 決定行列の作成
      *---------------------------------------*/
     $d_matrix = Dr::getDecisionMatrix($appro, $sample, $dc);
     //決定行列からDR算出
     //注意:決定行列から算出したDRは矛盾を含む
     $drs = Dr::calDR($d_matrix);
     /*-----------------------------------------
      * CI値の算出の作成
      *---------------------------------------*/
     $ci = Dr::getCI($drs);
     /*-----------------------------------------
      * 結果の出力
      *---------------------------------------*/
     echo "#DR" . PHP_EOL;
     fwrite($fp, "#DR" . PHP_EOL);
     // TODO: ファイルへ書き込み
     foreach ($ci as $key => $val) {
         echo "DC:" . $key . PHP_EOL;
         fwrite($fp, "DC:" . $key . PHP_EOL);
         // TODO: ファイルへ書き込み
         foreach ($val as $k => $v) {
             echo $k . " CI=" . sprintf("%0.4f", $v['ci']) . " " . "[" . implode(',', $v['sample']) . "]" . PHP_EOL;
             fwrite($fp, $k . " CI=" . sprintf("%0.4f", $v['ci']) . " " . "[" . implode(',', $v['sample']) . "]" . PHP_EOL);
             // TODO: ファイルへ書き込み
         }
         echo PHP_EOL;
         fwrite($fp, PHP_EOL);
         // TODO: ファイルへ書き込み
     }
     /*-----------------------------------------
      * 共起頻度・強度算出
      *---------------------------------------*/
     $cmat = Match::calMatchCoef($drh['drh']);
     echo "#MATCHING" . PHP_EOL;
     fwrite($fp, "#MATCHING" . PHP_EOL);
     // TODO: ファイルへ書き込み
     foreach ($cmat as $key => $val) {
         echo "DC:" . $key . PHP_EOL;
         fwrite($fp, "DC:" . $key . PHP_EOL);
         // TODO: ファイルへ書き込み
         foreach ($val as $k => $v) {
             echo $k . " j:" . sprintf("%0.4f", $v["jaccard"]) . " d:" . sprintf("%0.4f", $v["daice"]) . " c:" . sprintf("%0.4f", $v["cosine"]) . " s:" . sprintf("%0.4f", $v["simpson"]) . " kl:" . sprintf("%0.4f", $v["kl"]) . PHP_EOL;
             fwrite($fp, $k . " j:" . sprintf("%0.4f", $v["jaccard"]) . " d:" . sprintf("%0.4f", $v["daice"]) . " c:" . sprintf("%0.4f", $v["cosine"]) . " s:" . sprintf("%0.4f", $v["simpson"]) . " kl:" . sprintf("%0.4f", $v["kl"]) . PHP_EOL);
         }
         echo PHP_EOL;
         fwrite($fp, PHP_EOL);
         // TODO: ファイルへ書き込み
     }
     /*-----------------------------------------
      * 感性ワードの出現率の出力(Relative Frequency)
      *---------------------------------------*/
     fwrite($fp, "#RF" . PHP_EOL);
     // TODO: ファイルへ書き込み
     foreach ($review_percents as $key => $review_percent) {
         fwrite($fp, $key . " " . $review_percent . PHP_EOL);
     }
 }
예제 #18
0
                    
                    <div class="grid swiper-wrapper">
                        
                        <?php 
Chunk::get('gallery-nescafe-headstart');
?>
                        <?php 
Chunk::get('gallery-maggi');
?>
                        <?php 
Chunk::get('gallery-actwild');
?>
                        <?php 
Chunk::get('gallery-beneful');
?>
                        <?php 
Chunk::get('gallery-lumanetix');
?>
                        <?php 
Chunk::get('gallery-carnation');
?>
                        <?php 
Chunk::get('gallery-uncletobys');
?>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
예제 #19
0
 private function writeChunk(Chunk $chunk)
 {
     $binary = $chunk->toBinary(true);
     $index = LevelDB::chunkIndex($chunk->getX(), $chunk->getZ());
     $this->db->put($index . self::ENTRY_TERRAIN, substr($binary, 8, -1));
     $this->db->put($index . self::ENTRY_FLAGS, substr($binary, -1));
     $this->db->put($index . self::ENTRY_VERSION, "");
 }
예제 #20
0
 public function getEmptyChunk($chunkX, $chunkZ)
 {
     return Chunk::getEmptyChunk($chunkX, $chunkZ, $this);
 }
예제 #21
0
        </button>
    <?php 
}
?>

    <?php 
echo view('boomcms::editor.toolbar.view-live-button');
?>
</div>

<?php 
if ($version->getChunkType() === 'text') {
    ?>
    <?php 
    $chunk = Chunk::findById($version->getChunkType(), $version->getChunkId());
    $previousChunk = Chunk::find($version->getChunkType(), $chunk->slotname, $previous);
    $previousText = $previousChunk ? $previousChunk->site_text : '';
    ?>

    <script type="text/template"
            id="b-history-diff"
            data-slotname="<?php 
    echo $chunk->slotname;
    ?>
"
            data-type="<?php 
    echo $version->getChunkType();
    ?>
"
    >
        <?php