├── .gitignore ├── .travis.yml ├── README.md ├── ckip-test-driver-schedule.php ├── ckip-test-driver.php ├── composer.json ├── composer.lock ├── phpunit.xml ├── src └── CKIPClient.php └── test ├── CKIPClientTest.php └── bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /vendor/ 3 | /build/ 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # see http://about.travis-ci.org/docs/user/languages/php/ for more hints 2 | language: php 3 | 4 | # list any PHP version you want to test against 5 | php: 6 | # using major version aliases 7 | # aliased to a recent 5.4.x version 8 | - 5.4 9 | # aliased to a recent 5.5.x version 10 | - 5.5 11 | 12 | # optionally specify a list of environments, for example to test different RDBMS 13 | env: 14 | #- DB=mysql 15 | 16 | # execute any number of scripts before the test run, custom env's are available as variables 17 | before_script: 18 | #- if [[ "$DB" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS hello_world_test;" -uroot; fi 19 | - composer self-update 20 | - composer install --dev --prefer-source 21 | - mkdir -p build/logs 22 | 23 | # omitting "script:" will default to phpunit 24 | # use the $DB env variable to determine the phpunit.xml to use 25 | script: 26 | - vendor/bin/phpunit --configuration phpunit.xml --colors --coverage-text --coverage-clover build/logs/clover.xml 27 | 28 | # configure notifications (email, IRC, campfire etc) 29 | #notifications: 30 | #irc: "irc.freenode.org#travis" 31 | 32 | after_script: 33 | #- php vendor/bin/coveralls 34 | # or enable logging 35 | - vendor/bin/coveralls -v 36 | #- vendor/bin/coveralls -c tests/coveralls.yml -v -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CKIPClient-PHP 中研院斷詞系統客戶端程式 2 | 3 | [![Build Status](https://travis-ci.org/fukuball/CKIPClient-PHP.png?branch=master)](https://travis-ci.org/fukuball/CKIPClient-PHP) 4 | [![Coverage Status](https://coveralls.io/repos/fukuball/CKIPClient-PHP/badge.png?branch=master)](https://coveralls.io/r/fukuball/CKIPClient-PHP?branch=master) 5 | [![Latest Stable Version](https://poser.pugx.org/fukuball/ckip-client-php/v/stable.png)](https://packagist.org/packages/fukuball/ckip-client-php) 6 | 7 | 自然語言處理系統最基本需要讓電腦能夠分辨文本中字詞的意義,才能夠更進一步發展出自然語言處理系統的相關演算法,其中斷詞處理便是一個重要的前置技術,而中研院的[斷詞系統](http://ckipsvr.iis.sinica.edu.tw/)便是一個處理中文斷詞的系統 8 | 9 | 重新撰寫中研院斷詞系統的客戶端程式,主要是想讓有中文斷詞需求的研究者或程式人員可以專注於開發自己的核心演算法,中研院官方提供的客戶端程式已有很長一段時間沒有更新維護,以我自己的經驗是用得非常不愉快, CKIPClient-PHP 可以將這些不愉快都趕走! 10 | 11 | 中文斷詞系統還有 [Stanford Word Segmenter](http://nlp.stanford.edu/software/segmenter.shtml) 這個選擇,不過需要先將文本轉成簡體字再給 Stanford Word Segmenter 進行斷詞才會有比較好的效果,但為了支持國產還是鼓勵大家多多使用中研院的斷詞系統,或許多多使用未來中研院的斷詞系統會就變得越來越好(?) 12 | 13 | ## 注意事項 14 | 15 | ### [申請帳號](http://ckipsvr.iis.sinica.edu.tw/) 16 | 17 | 請使用「[線上服務申請](http://ckipsvr.iis.sinica.edu.tw/)」進行申請帳號的作業,由於中研院斷詞系統的網頁使用 frame 來寫,所以原諒我無法直接貼連結給各位,自行找「線上服務申請」這個連結吧!根據經驗申請作業需要幾個工作天,只能耐心等待了。 18 | 19 | ### 中研院斷詞系統每天上午六點進行系統維護 20 | 21 | 請注意中研院斷詞系統每天上午六點進行系統維護,每次維護期間大概半小時,這段時間請不要執行程式或是進行重要的排程工作,否則可能會得到非預期的結果。 22 | 23 | ### 不要一次送出大量資料,也不要密集送出資料 24 | 25 | 這點是我個人經驗,若一次送出大量資料,得到的回傳 xml 會不完整,造成 parse error,所以我會先自行將文章進行斷句(利用標點符號斷句),再送出給斷詞系統。也請注意不要密集送出資料給中研院斷詞系統,否則會暫時被鎖住帳號,可以在每次送出資料後,讓 script sleep 幾秒鐘,如此就不會被鎖住帳號了。如何自行斷句送出資料給斷詞系統可參考:[schedule-ckip-test-driver.php](https://github.com/fukuball/CKIPClient-PHP/blob/master/schedule-ckip-test-driver.php) 26 | 27 | ### 擁有能夠執行 PHP 程式的環境 28 | 29 | 使用 CKIPClient-PHP 必須先在自己的機器上安裝好能夠執行 PHP 程式的環境。 30 | 31 | ## 使用方式 32 | 33 | **CKIPClient-PHP** 提供 CKIPClient.php 作為串接[中研院斷詞系統](http://ckipsvr.iis.sinica.edu.tw/)的介面程式類別, ckip-test-driver.php 是簡單的範例程式,可以直接執行這支程式來觀察斷詞結果。 34 | 35 | 首先必須先將 CKIPClient.php 類別程式匯進需要使用到斷詞的 PHP 程式: 36 | 37 | require_once "src/CKIPClient.php"; 38 | 39 | 接下來使用「線上服務申請」中取得的 server ip 、 server port 、 username 及 password 初始化 CKIPClient 物件: 40 | 41 | $ckip_client_obj = new CKIPClient( 42 | CKIP_SERVER, 43 | CKIP_PORT, 44 | CKIP_USERNAME, 45 | CKIP_PASSWORD 46 | ); 47 | 48 | 再來就可以使用 CKIPClient 物件來處理斷詞了,將需要斷詞的文件組成如下格式: 49 | 50 | $raw_text = "獨立音樂需要大家一起來推廣,\n". 51 | "歡迎加入我們的行列!\n"; 52 | $return_text = $ckip_client_obj->send($raw_text); 53 | 54 | 上述的範例中,我有進行前處理將文件分段,這樣斷詞出來的效果會比較好,使用一整個文件進行斷詞也可以的,但是建議一個句子(標點符號之間的字數)不要超過 80 個字: 55 | 56 | $raw_text = "獨立音樂需要大家一起來推廣,歡迎加入我們的行列!"; 57 | $return_text = $ckip_client_obj->send($raw_text); 58 | 59 | 經過上述步驟之後就可以進行回傳文件的剖析,可以得到文件的斷句結果也可以得到文件的斷詞結果: 60 | 61 | 取得斷句結果 62 | 63 | $return_sentences = $ckip_client_obj->getSentence(); 64 | print_r($return_sentences); 65 | 66 | 斷句結果會取得一個斷句陣列: 67 | 68 | Array 69 | ( 70 | [0] =>  獨立(Vi) 音樂(N) 需要(Vt) 大家(N) 一起(ADV) 來(ADV) 推廣(Vt) ,(COMMACATEGORY) 71 | [1] =>  歡迎(Vt) 加入(Vt) 我們(N) 的(T) 行列(N) !(EXCLAMATIONCATEGORY) 72 | ) 73 | 74 | 取得斷詞結果 75 | 76 | $return_terms = $ckip_client_obj->getTerm(); 77 | print_r($return_terms); 78 | 79 | 斷詞結果會取得一個斷詞陣列,其中 term 代表斷詞, tag 代表斷詞的詞性,如動詞、名詞等等,詳細詞性列表可參考[中研院斷詞系統](http://ckipsvr.iis.sinica.edu.tw/): 80 | 81 | Array 82 | ( 83 | [0] => Array 84 | ( 85 | [term] => 獨立 86 | [tag] => Vi 87 | ) 88 | [1] => Array 89 | ( 90 | [term] => 音樂 91 | [tag] => N 92 | ) 93 | [2] => Array 94 | ( 95 | [term] => 需要 96 | [tag] => Vt 97 | ) 98 | [3] => Array 99 | ( 100 | [term] => 大家 101 | [tag] => N 102 | ) 103 | [4] => Array 104 | ( 105 | [term] => 一起 106 | [tag] => ADV 107 | ) 108 | [5] => Array 109 | ( 110 | [term] => 來 111 | [tag] => ADV 112 | ) 113 | [6] => Array 114 | ( 115 | [term] => 推廣 116 | [tag] => Vt 117 | ) 118 | [7] => Array 119 | ( 120 | [term] => , 121 | [tag] => COMMACATEGORY 122 | ) 123 | [8] => Array 124 | ( 125 | [term] => 歡迎 126 | [tag] => Vt 127 | ) 128 | [9] => Array 129 | ( 130 | [term] => 加入 131 | [tag] => Vt 132 | ) 133 | [10] => Array 134 | ( 135 | [term] => 我們 136 | [tag] => N 137 | ) 138 | [11] => Array 139 | ( 140 | [term] => 的 141 | [tag] => T 142 | ) 143 | [12] => Array 144 | ( 145 | [term] => 行列 146 | [tag] => N 147 | ) 148 | [13] => Array 149 | ( 150 | [term] => ! 151 | [tag] => EXCLAMATIONCATEGORY 152 | ) 153 | ) 154 | 155 | ## License 156 | 157 | Released under the [MIT License](http://opensource.org/licenses/MIT). 158 | 159 | 160 | ## Contact 161 | 162 | 若有任何問題可以與我聯繫,也歡迎大家幫忙修正 CKIPClient-PHP ! 163 | 164 | * Twitter: [@fukuball](https://twitter.com/fukuball) 165 | * Gmail: fukuball@gmail.com -------------------------------------------------------------------------------- /ckip-test-driver-schedule.php: -------------------------------------------------------------------------------- 1 | 10 | * @license No Licence 11 | * @version Release: <1.0> 12 | * @link http://fukuball@github.com 13 | */ 14 | 15 | require_once "src/CKIPClient.php"; 16 | 17 | // change to yours 18 | define("CKIP_SERVER", "000.000.000.000"); 19 | define("CKIP_PORT", 0000); 20 | define("CKIP_USERNAME", "xxxxxx"); 21 | define("CKIP_PASSWORD", "xxxxxxxxx"); 22 | 23 | $ckip_client_obj = new CKIPClient( 24 | CKIP_SERVER, 25 | CKIP_PORT, 26 | CKIP_USERNAME, 27 | CKIP_PASSWORD 28 | ); 29 | 30 | $raw_text = "獨立音樂需要大家一起來推廣,歡迎加入我們的行列。"; 31 | 32 | $raw_text = str_replace(",", "\n", $raw_text); 33 | $raw_text = str_replace("。", "\n", $raw_text); 34 | $raw_text = str_replace(",", "\n", $raw_text); 35 | $raw_text = str_replace(".", "\n", $raw_text); 36 | 37 | $raw_text_array = explode("\n", $raw_text); 38 | $raw_text_array = array_filter($raw_text_array); 39 | 40 | foreach ($raw_text_array as $raw_sentence) { 41 | 42 | $return_text = $ckip_client_obj->send($raw_sentence); 43 | echo $return_text; 44 | 45 | $return_term = $ckip_client_obj->getTerm(); 46 | print_r($return_term); 47 | 48 | sleep(5); 49 | 50 | } 51 | 52 | 53 | ?> -------------------------------------------------------------------------------- /ckip-test-driver.php: -------------------------------------------------------------------------------- 1 | 10 | * @license No Licence 11 | * @version Release: <1.0> 12 | * @link http://fukuball@github.com 13 | */ 14 | 15 | require_once "src/CKIPClient.php"; 16 | 17 | // change to yours 18 | define("CKIP_SERVER", "000.000.000.000"); 19 | define("CKIP_PORT", 0000); 20 | define("CKIP_USERNAME", "xxxxxx"); 21 | define("CKIP_PASSWORD", "xxxxxxxxx"); 22 | 23 | $ckip_client_obj = new CKIPClient( 24 | CKIP_SERVER, 25 | CKIP_PORT, 26 | CKIP_USERNAME, 27 | CKIP_PASSWORD 28 | ); 29 | 30 | $raw_text = "獨立音樂需要大家一起來推廣,\n". 31 | "歡迎加入我們的行列!。\n"; 32 | 33 | $return_text = $ckip_client_obj->send($raw_text); 34 | echo $return_text; 35 | 36 | $return_sentence = $ckip_client_obj->getSentence(); 37 | print_r($return_sentence); 38 | 39 | $return_term = $ckip_client_obj->getTerm(); 40 | print_r($return_term); 41 | 42 | ?> -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fukuball/ckip-client-php", 3 | "description": "中研院斷詞系統的 Client 端程式,讓有中文斷詞需求的研究者或程式人員可以專注於開發自己的核心演算法。", 4 | "require-dev": { 5 | "phpunit/phpunit": ">=3.7.0", 6 | "satooshi/php-coveralls": "dev-master" 7 | }, 8 | "license": "MIT", 9 | "authors": [ 10 | { 11 | "name": "Fukuball Lin", 12 | "email": "fukuball@gmail.com" 13 | } 14 | ], 15 | "minimum-stability": "stable", 16 | "require": { 17 | "php": ">= 5.3" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" 5 | ], 6 | "hash": "520210dc8ec302198baacfb5629126a3", 7 | "packages": [ 8 | 9 | ], 10 | "packages-dev": [ 11 | { 12 | "name": "guzzle/guzzle", 13 | "version": "v3.8.0", 14 | "source": { 15 | "type": "git", 16 | "url": "https://github.com/guzzle/guzzle.git", 17 | "reference": "b4a3ce8c05e777fa18b802956d5d0e38ad338a69" 18 | }, 19 | "dist": { 20 | "type": "zip", 21 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b4a3ce8c05e777fa18b802956d5d0e38ad338a69", 22 | "reference": "b4a3ce8c05e777fa18b802956d5d0e38ad338a69", 23 | "shasum": "" 24 | }, 25 | "require": { 26 | "ext-curl": "*", 27 | "php": ">=5.3.3", 28 | "symfony/event-dispatcher": ">=2.1" 29 | }, 30 | "replace": { 31 | "guzzle/batch": "self.version", 32 | "guzzle/cache": "self.version", 33 | "guzzle/common": "self.version", 34 | "guzzle/http": "self.version", 35 | "guzzle/inflection": "self.version", 36 | "guzzle/iterator": "self.version", 37 | "guzzle/log": "self.version", 38 | "guzzle/parser": "self.version", 39 | "guzzle/plugin": "self.version", 40 | "guzzle/plugin-async": "self.version", 41 | "guzzle/plugin-backoff": "self.version", 42 | "guzzle/plugin-cache": "self.version", 43 | "guzzle/plugin-cookie": "self.version", 44 | "guzzle/plugin-curlauth": "self.version", 45 | "guzzle/plugin-error-response": "self.version", 46 | "guzzle/plugin-history": "self.version", 47 | "guzzle/plugin-log": "self.version", 48 | "guzzle/plugin-md5": "self.version", 49 | "guzzle/plugin-mock": "self.version", 50 | "guzzle/plugin-oauth": "self.version", 51 | "guzzle/service": "self.version", 52 | "guzzle/stream": "self.version" 53 | }, 54 | "require-dev": { 55 | "doctrine/cache": "*", 56 | "monolog/monolog": "1.*", 57 | "phpunit/phpunit": "3.7.*", 58 | "psr/log": "1.0.*", 59 | "symfony/class-loader": "*", 60 | "zendframework/zend-cache": "2.0.*", 61 | "zendframework/zend-log": "2.0.*" 62 | }, 63 | "type": "library", 64 | "extra": { 65 | "branch-alias": { 66 | "dev-master": "3.8-dev" 67 | } 68 | }, 69 | "autoload": { 70 | "psr-0": { 71 | "Guzzle\\Tests": "tests/", 72 | "Guzzle": "src/" 73 | } 74 | }, 75 | "notification-url": "https://packagist.org/downloads/", 76 | "license": [ 77 | "MIT" 78 | ], 79 | "authors": [ 80 | { 81 | "name": "Michael Dowling", 82 | "email": "mtdowling@gmail.com", 83 | "homepage": "https://github.com/mtdowling" 84 | }, 85 | { 86 | "name": "Guzzle Community", 87 | "homepage": "https://github.com/guzzle/guzzle/contributors" 88 | } 89 | ], 90 | "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", 91 | "homepage": "http://guzzlephp.org/", 92 | "keywords": [ 93 | "client", 94 | "curl", 95 | "framework", 96 | "http", 97 | "http client", 98 | "rest", 99 | "web service" 100 | ], 101 | "time": "2013-12-05 23:39:20" 102 | }, 103 | { 104 | "name": "phpunit/php-code-coverage", 105 | "version": "1.2.13", 106 | "source": { 107 | "type": "git", 108 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 109 | "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94" 110 | }, 111 | "dist": { 112 | "type": "zip", 113 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", 114 | "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", 115 | "shasum": "" 116 | }, 117 | "require": { 118 | "php": ">=5.3.3", 119 | "phpunit/php-file-iterator": ">=1.3.0@stable", 120 | "phpunit/php-text-template": ">=1.1.1@stable", 121 | "phpunit/php-token-stream": ">=1.1.3@stable" 122 | }, 123 | "require-dev": { 124 | "phpunit/phpunit": "3.7.*@dev" 125 | }, 126 | "suggest": { 127 | "ext-dom": "*", 128 | "ext-xdebug": ">=2.0.5" 129 | }, 130 | "type": "library", 131 | "extra": { 132 | "branch-alias": { 133 | "dev-master": "1.2.x-dev" 134 | } 135 | }, 136 | "autoload": { 137 | "classmap": [ 138 | "PHP/" 139 | ] 140 | }, 141 | "notification-url": "https://packagist.org/downloads/", 142 | "include-path": [ 143 | "" 144 | ], 145 | "license": [ 146 | "BSD-3-Clause" 147 | ], 148 | "authors": [ 149 | { 150 | "name": "Sebastian Bergmann", 151 | "email": "sb@sebastian-bergmann.de", 152 | "role": "lead" 153 | } 154 | ], 155 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 156 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 157 | "keywords": [ 158 | "coverage", 159 | "testing", 160 | "xunit" 161 | ], 162 | "time": "2013-09-10 08:14:32" 163 | }, 164 | { 165 | "name": "phpunit/php-file-iterator", 166 | "version": "1.3.4", 167 | "source": { 168 | "type": "git", 169 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 170 | "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" 171 | }, 172 | "dist": { 173 | "type": "zip", 174 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", 175 | "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", 176 | "shasum": "" 177 | }, 178 | "require": { 179 | "php": ">=5.3.3" 180 | }, 181 | "type": "library", 182 | "autoload": { 183 | "classmap": [ 184 | "File/" 185 | ] 186 | }, 187 | "notification-url": "https://packagist.org/downloads/", 188 | "include-path": [ 189 | "" 190 | ], 191 | "license": [ 192 | "BSD-3-Clause" 193 | ], 194 | "authors": [ 195 | { 196 | "name": "Sebastian Bergmann", 197 | "email": "sb@sebastian-bergmann.de", 198 | "role": "lead" 199 | } 200 | ], 201 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 202 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 203 | "keywords": [ 204 | "filesystem", 205 | "iterator" 206 | ], 207 | "time": "2013-10-10 15:34:57" 208 | }, 209 | { 210 | "name": "phpunit/php-text-template", 211 | "version": "1.1.4", 212 | "source": { 213 | "type": "git", 214 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 215 | "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23" 216 | }, 217 | "dist": { 218 | "type": "zip", 219 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5180896f51c5b3648ac946b05f9ec02be78a0b23", 220 | "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23", 221 | "shasum": "" 222 | }, 223 | "require": { 224 | "php": ">=5.3.3" 225 | }, 226 | "type": "library", 227 | "autoload": { 228 | "classmap": [ 229 | "Text/" 230 | ] 231 | }, 232 | "notification-url": "https://packagist.org/downloads/", 233 | "include-path": [ 234 | "" 235 | ], 236 | "license": [ 237 | "BSD-3-Clause" 238 | ], 239 | "authors": [ 240 | { 241 | "name": "Sebastian Bergmann", 242 | "email": "sb@sebastian-bergmann.de", 243 | "role": "lead" 244 | } 245 | ], 246 | "description": "Simple template engine.", 247 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 248 | "keywords": [ 249 | "template" 250 | ], 251 | "time": "2012-10-31 18:15:28" 252 | }, 253 | { 254 | "name": "phpunit/php-timer", 255 | "version": "1.0.5", 256 | "source": { 257 | "type": "git", 258 | "url": "https://github.com/sebastianbergmann/php-timer.git", 259 | "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" 260 | }, 261 | "dist": { 262 | "type": "zip", 263 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", 264 | "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", 265 | "shasum": "" 266 | }, 267 | "require": { 268 | "php": ">=5.3.3" 269 | }, 270 | "type": "library", 271 | "autoload": { 272 | "classmap": [ 273 | "PHP/" 274 | ] 275 | }, 276 | "notification-url": "https://packagist.org/downloads/", 277 | "include-path": [ 278 | "" 279 | ], 280 | "license": [ 281 | "BSD-3-Clause" 282 | ], 283 | "authors": [ 284 | { 285 | "name": "Sebastian Bergmann", 286 | "email": "sb@sebastian-bergmann.de", 287 | "role": "lead" 288 | } 289 | ], 290 | "description": "Utility class for timing", 291 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 292 | "keywords": [ 293 | "timer" 294 | ], 295 | "time": "2013-08-02 07:42:54" 296 | }, 297 | { 298 | "name": "phpunit/php-token-stream", 299 | "version": "1.2.1", 300 | "source": { 301 | "type": "git", 302 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 303 | "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e" 304 | }, 305 | "dist": { 306 | "type": "zip", 307 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", 308 | "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", 309 | "shasum": "" 310 | }, 311 | "require": { 312 | "ext-tokenizer": "*", 313 | "php": ">=5.3.3" 314 | }, 315 | "type": "library", 316 | "extra": { 317 | "branch-alias": { 318 | "dev-master": "1.2-dev" 319 | } 320 | }, 321 | "autoload": { 322 | "classmap": [ 323 | "PHP/" 324 | ] 325 | }, 326 | "notification-url": "https://packagist.org/downloads/", 327 | "include-path": [ 328 | "" 329 | ], 330 | "license": [ 331 | "BSD-3-Clause" 332 | ], 333 | "authors": [ 334 | { 335 | "name": "Sebastian Bergmann", 336 | "email": "sb@sebastian-bergmann.de", 337 | "role": "lead" 338 | } 339 | ], 340 | "description": "Wrapper around PHP's tokenizer extension.", 341 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 342 | "keywords": [ 343 | "tokenizer" 344 | ], 345 | "time": "2013-09-13 04:58:23" 346 | }, 347 | { 348 | "name": "phpunit/phpunit", 349 | "version": "3.7.28", 350 | "source": { 351 | "type": "git", 352 | "url": "https://github.com/sebastianbergmann/phpunit.git", 353 | "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d" 354 | }, 355 | "dist": { 356 | "type": "zip", 357 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", 358 | "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", 359 | "shasum": "" 360 | }, 361 | "require": { 362 | "ext-dom": "*", 363 | "ext-pcre": "*", 364 | "ext-reflection": "*", 365 | "ext-spl": "*", 366 | "php": ">=5.3.3", 367 | "phpunit/php-code-coverage": "~1.2.1", 368 | "phpunit/php-file-iterator": ">=1.3.1", 369 | "phpunit/php-text-template": ">=1.1.1", 370 | "phpunit/php-timer": ">=1.0.4", 371 | "phpunit/phpunit-mock-objects": "~1.2.0", 372 | "symfony/yaml": "~2.0" 373 | }, 374 | "require-dev": { 375 | "pear-pear/pear": "1.9.4" 376 | }, 377 | "suggest": { 378 | "ext-json": "*", 379 | "ext-simplexml": "*", 380 | "ext-tokenizer": "*", 381 | "phpunit/php-invoker": ">=1.1.0,<1.2.0" 382 | }, 383 | "bin": [ 384 | "composer/bin/phpunit" 385 | ], 386 | "type": "library", 387 | "extra": { 388 | "branch-alias": { 389 | "dev-master": "3.7.x-dev" 390 | } 391 | }, 392 | "autoload": { 393 | "classmap": [ 394 | "PHPUnit/" 395 | ] 396 | }, 397 | "notification-url": "https://packagist.org/downloads/", 398 | "include-path": [ 399 | "", 400 | "../../symfony/yaml/" 401 | ], 402 | "license": [ 403 | "BSD-3-Clause" 404 | ], 405 | "authors": [ 406 | { 407 | "name": "Sebastian Bergmann", 408 | "email": "sebastian@phpunit.de", 409 | "role": "lead" 410 | } 411 | ], 412 | "description": "The PHP Unit Testing framework.", 413 | "homepage": "http://www.phpunit.de/", 414 | "keywords": [ 415 | "phpunit", 416 | "testing", 417 | "xunit" 418 | ], 419 | "time": "2013-10-17 07:27:40" 420 | }, 421 | { 422 | "name": "phpunit/phpunit-mock-objects", 423 | "version": "1.2.3", 424 | "source": { 425 | "type": "git", 426 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 427 | "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" 428 | }, 429 | "dist": { 430 | "type": "zip", 431 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", 432 | "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", 433 | "shasum": "" 434 | }, 435 | "require": { 436 | "php": ">=5.3.3", 437 | "phpunit/php-text-template": ">=1.1.1@stable" 438 | }, 439 | "suggest": { 440 | "ext-soap": "*" 441 | }, 442 | "type": "library", 443 | "autoload": { 444 | "classmap": [ 445 | "PHPUnit/" 446 | ] 447 | }, 448 | "notification-url": "https://packagist.org/downloads/", 449 | "include-path": [ 450 | "" 451 | ], 452 | "license": [ 453 | "BSD-3-Clause" 454 | ], 455 | "authors": [ 456 | { 457 | "name": "Sebastian Bergmann", 458 | "email": "sb@sebastian-bergmann.de", 459 | "role": "lead" 460 | } 461 | ], 462 | "description": "Mock Object library for PHPUnit", 463 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 464 | "keywords": [ 465 | "mock", 466 | "xunit" 467 | ], 468 | "time": "2013-01-13 10:24:48" 469 | }, 470 | { 471 | "name": "psr/log", 472 | "version": "1.0.0", 473 | "source": { 474 | "type": "git", 475 | "url": "https://github.com/php-fig/log.git", 476 | "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" 477 | }, 478 | "dist": { 479 | "type": "zip", 480 | "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", 481 | "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", 482 | "shasum": "" 483 | }, 484 | "type": "library", 485 | "autoload": { 486 | "psr-0": { 487 | "Psr\\Log\\": "" 488 | } 489 | }, 490 | "notification-url": "https://packagist.org/downloads/", 491 | "license": [ 492 | "MIT" 493 | ], 494 | "authors": [ 495 | { 496 | "name": "PHP-FIG", 497 | "homepage": "http://www.php-fig.org/" 498 | } 499 | ], 500 | "description": "Common interface for logging libraries", 501 | "keywords": [ 502 | "log", 503 | "psr", 504 | "psr-3" 505 | ], 506 | "time": "2012-12-21 11:40:51" 507 | }, 508 | { 509 | "name": "satooshi/php-coveralls", 510 | "version": "dev-master", 511 | "source": { 512 | "type": "git", 513 | "url": "https://github.com/satooshi/php-coveralls.git", 514 | "reference": "c95c07e971e4b687718f54fc3447a260fb989e16" 515 | }, 516 | "dist": { 517 | "type": "zip", 518 | "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/c95c07e971e4b687718f54fc3447a260fb989e16", 519 | "reference": "c95c07e971e4b687718f54fc3447a260fb989e16", 520 | "shasum": "" 521 | }, 522 | "require": { 523 | "ext-json": "*", 524 | "ext-simplexml": "*", 525 | "guzzle/guzzle": ">=3.0", 526 | "php": ">=5.3", 527 | "psr/log": "1.0.0", 528 | "symfony/config": ">=2.0", 529 | "symfony/console": ">=2.0", 530 | "symfony/stopwatch": ">=2.2", 531 | "symfony/yaml": ">=2.0" 532 | }, 533 | "require-dev": { 534 | "apigen/apigen": "2.8.*@stable", 535 | "pdepend/pdepend": "dev-master", 536 | "phpmd/phpmd": "dev-master", 537 | "phpunit/php-invoker": ">=1.1.0,<1.2.0", 538 | "phpunit/phpunit": "3.7.*@stable", 539 | "sebastian/finder-facade": "dev-master", 540 | "sebastian/phpcpd": "1.4.*@stable", 541 | "squizlabs/php_codesniffer": "1.4.*@stable", 542 | "theseer/fdomdocument": "dev-master" 543 | }, 544 | "suggest": { 545 | "symfony/http-kernel": "Allows Symfony integration" 546 | }, 547 | "bin": [ 548 | "composer/bin/coveralls" 549 | ], 550 | "type": "library", 551 | "autoload": { 552 | "psr-0": { 553 | "Satooshi\\Component": "src/", 554 | "Satooshi\\Bundle": "src/" 555 | } 556 | }, 557 | "notification-url": "https://packagist.org/downloads/", 558 | "license": [ 559 | "MIT" 560 | ], 561 | "authors": [ 562 | { 563 | "name": "Kitamura Satoshi", 564 | "email": "with.no.parachute@gmail.com", 565 | "homepage": "https://www.facebook.com/satooshi.jp" 566 | } 567 | ], 568 | "description": "PHP client library for Coveralls API", 569 | "homepage": "https://github.com/satooshi/php-coveralls", 570 | "keywords": [ 571 | "ci", 572 | "coverage", 573 | "github", 574 | "test" 575 | ], 576 | "time": "2013-07-25 11:22:39" 577 | }, 578 | { 579 | "name": "symfony/config", 580 | "version": "v2.4.0", 581 | "target-dir": "Symfony/Component/Config", 582 | "source": { 583 | "type": "git", 584 | "url": "https://github.com/symfony/Config.git", 585 | "reference": "16068f76c0af74968f3ad8fcec3eb90df1fde394" 586 | }, 587 | "dist": { 588 | "type": "zip", 589 | "url": "https://api.github.com/repos/symfony/Config/zipball/16068f76c0af74968f3ad8fcec3eb90df1fde394", 590 | "reference": "16068f76c0af74968f3ad8fcec3eb90df1fde394", 591 | "shasum": "" 592 | }, 593 | "require": { 594 | "php": ">=5.3.3", 595 | "symfony/filesystem": "~2.3" 596 | }, 597 | "type": "library", 598 | "extra": { 599 | "branch-alias": { 600 | "dev-master": "2.4-dev" 601 | } 602 | }, 603 | "autoload": { 604 | "psr-0": { 605 | "Symfony\\Component\\Config\\": "" 606 | } 607 | }, 608 | "notification-url": "https://packagist.org/downloads/", 609 | "license": [ 610 | "MIT" 611 | ], 612 | "authors": [ 613 | { 614 | "name": "Fabien Potencier", 615 | "email": "fabien@symfony.com" 616 | }, 617 | { 618 | "name": "Symfony Community", 619 | "homepage": "http://symfony.com/contributors" 620 | } 621 | ], 622 | "description": "Symfony Config Component", 623 | "homepage": "http://symfony.com", 624 | "time": "2013-11-26 16:40:27" 625 | }, 626 | { 627 | "name": "symfony/console", 628 | "version": "v2.4.0", 629 | "target-dir": "Symfony/Component/Console", 630 | "source": { 631 | "type": "git", 632 | "url": "https://github.com/symfony/Console.git", 633 | "reference": "3c1496ae96d24ccc6c340fcc25f71d7a1ab4c12c" 634 | }, 635 | "dist": { 636 | "type": "zip", 637 | "url": "https://api.github.com/repos/symfony/Console/zipball/3c1496ae96d24ccc6c340fcc25f71d7a1ab4c12c", 638 | "reference": "3c1496ae96d24ccc6c340fcc25f71d7a1ab4c12c", 639 | "shasum": "" 640 | }, 641 | "require": { 642 | "php": ">=5.3.3" 643 | }, 644 | "require-dev": { 645 | "symfony/event-dispatcher": "~2.1" 646 | }, 647 | "suggest": { 648 | "symfony/event-dispatcher": "" 649 | }, 650 | "type": "library", 651 | "extra": { 652 | "branch-alias": { 653 | "dev-master": "2.4-dev" 654 | } 655 | }, 656 | "autoload": { 657 | "psr-0": { 658 | "Symfony\\Component\\Console\\": "" 659 | } 660 | }, 661 | "notification-url": "https://packagist.org/downloads/", 662 | "license": [ 663 | "MIT" 664 | ], 665 | "authors": [ 666 | { 667 | "name": "Fabien Potencier", 668 | "email": "fabien@symfony.com" 669 | }, 670 | { 671 | "name": "Symfony Community", 672 | "homepage": "http://symfony.com/contributors" 673 | } 674 | ], 675 | "description": "Symfony Console Component", 676 | "homepage": "http://symfony.com", 677 | "time": "2013-11-27 09:10:40" 678 | }, 679 | { 680 | "name": "symfony/event-dispatcher", 681 | "version": "v2.4.0", 682 | "target-dir": "Symfony/Component/EventDispatcher", 683 | "source": { 684 | "type": "git", 685 | "url": "https://github.com/symfony/EventDispatcher.git", 686 | "reference": "acd1707236f6eb96fbb8d58f63d289b72ebc2f6e" 687 | }, 688 | "dist": { 689 | "type": "zip", 690 | "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/acd1707236f6eb96fbb8d58f63d289b72ebc2f6e", 691 | "reference": "acd1707236f6eb96fbb8d58f63d289b72ebc2f6e", 692 | "shasum": "" 693 | }, 694 | "require": { 695 | "php": ">=5.3.3" 696 | }, 697 | "require-dev": { 698 | "symfony/dependency-injection": "~2.0" 699 | }, 700 | "suggest": { 701 | "symfony/dependency-injection": "", 702 | "symfony/http-kernel": "" 703 | }, 704 | "type": "library", 705 | "extra": { 706 | "branch-alias": { 707 | "dev-master": "2.4-dev" 708 | } 709 | }, 710 | "autoload": { 711 | "psr-0": { 712 | "Symfony\\Component\\EventDispatcher\\": "" 713 | } 714 | }, 715 | "notification-url": "https://packagist.org/downloads/", 716 | "license": [ 717 | "MIT" 718 | ], 719 | "authors": [ 720 | { 721 | "name": "Fabien Potencier", 722 | "email": "fabien@symfony.com" 723 | }, 724 | { 725 | "name": "Symfony Community", 726 | "homepage": "http://symfony.com/contributors" 727 | } 728 | ], 729 | "description": "Symfony EventDispatcher Component", 730 | "homepage": "http://symfony.com", 731 | "time": "2013-12-03 14:52:22" 732 | }, 733 | { 734 | "name": "symfony/filesystem", 735 | "version": "v2.4.0", 736 | "target-dir": "Symfony/Component/Filesystem", 737 | "source": { 738 | "type": "git", 739 | "url": "https://github.com/symfony/Filesystem.git", 740 | "reference": "79acd777762e81d0f3414ca25a602deeeb48240d" 741 | }, 742 | "dist": { 743 | "type": "zip", 744 | "url": "https://api.github.com/repos/symfony/Filesystem/zipball/79acd777762e81d0f3414ca25a602deeeb48240d", 745 | "reference": "79acd777762e81d0f3414ca25a602deeeb48240d", 746 | "shasum": "" 747 | }, 748 | "require": { 749 | "php": ">=5.3.3" 750 | }, 751 | "type": "library", 752 | "extra": { 753 | "branch-alias": { 754 | "dev-master": "2.4-dev" 755 | } 756 | }, 757 | "autoload": { 758 | "psr-0": { 759 | "Symfony\\Component\\Filesystem\\": "" 760 | } 761 | }, 762 | "notification-url": "https://packagist.org/downloads/", 763 | "license": [ 764 | "MIT" 765 | ], 766 | "authors": [ 767 | { 768 | "name": "Fabien Potencier", 769 | "email": "fabien@symfony.com" 770 | }, 771 | { 772 | "name": "Symfony Community", 773 | "homepage": "http://symfony.com/contributors" 774 | } 775 | ], 776 | "description": "Symfony Filesystem Component", 777 | "homepage": "http://symfony.com", 778 | "time": "2013-11-16 15:13:54" 779 | }, 780 | { 781 | "name": "symfony/stopwatch", 782 | "version": "v2.4.0", 783 | "target-dir": "Symfony/Component/Stopwatch", 784 | "source": { 785 | "type": "git", 786 | "url": "https://github.com/symfony/Stopwatch.git", 787 | "reference": "b43d5cc4e6405ee5aab692f991048ec18d598785" 788 | }, 789 | "dist": { 790 | "type": "zip", 791 | "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b43d5cc4e6405ee5aab692f991048ec18d598785", 792 | "reference": "b43d5cc4e6405ee5aab692f991048ec18d598785", 793 | "shasum": "" 794 | }, 795 | "require": { 796 | "php": ">=5.3.3" 797 | }, 798 | "type": "library", 799 | "extra": { 800 | "branch-alias": { 801 | "dev-master": "2.4-dev" 802 | } 803 | }, 804 | "autoload": { 805 | "psr-0": { 806 | "Symfony\\Component\\Stopwatch\\": "" 807 | } 808 | }, 809 | "notification-url": "https://packagist.org/downloads/", 810 | "license": [ 811 | "MIT" 812 | ], 813 | "authors": [ 814 | { 815 | "name": "Fabien Potencier", 816 | "email": "fabien@symfony.com" 817 | }, 818 | { 819 | "name": "Symfony Community", 820 | "homepage": "http://symfony.com/contributors" 821 | } 822 | ], 823 | "description": "Symfony Stopwatch Component", 824 | "homepage": "http://symfony.com", 825 | "time": "2013-11-11 18:40:07" 826 | }, 827 | { 828 | "name": "symfony/yaml", 829 | "version": "v2.4.0", 830 | "target-dir": "Symfony/Component/Yaml", 831 | "source": { 832 | "type": "git", 833 | "url": "https://github.com/symfony/Yaml.git", 834 | "reference": "1ae235a1b9d3ad3d9f3860ff20acc072df95b7f5" 835 | }, 836 | "dist": { 837 | "type": "zip", 838 | "url": "https://api.github.com/repos/symfony/Yaml/zipball/1ae235a1b9d3ad3d9f3860ff20acc072df95b7f5", 839 | "reference": "1ae235a1b9d3ad3d9f3860ff20acc072df95b7f5", 840 | "shasum": "" 841 | }, 842 | "require": { 843 | "php": ">=5.3.3" 844 | }, 845 | "type": "library", 846 | "extra": { 847 | "branch-alias": { 848 | "dev-master": "2.4-dev" 849 | } 850 | }, 851 | "autoload": { 852 | "psr-0": { 853 | "Symfony\\Component\\Yaml\\": "" 854 | } 855 | }, 856 | "notification-url": "https://packagist.org/downloads/", 857 | "license": [ 858 | "MIT" 859 | ], 860 | "authors": [ 861 | { 862 | "name": "Fabien Potencier", 863 | "email": "fabien@symfony.com" 864 | }, 865 | { 866 | "name": "Symfony Community", 867 | "homepage": "http://symfony.com/contributors" 868 | } 869 | ], 870 | "description": "Symfony Yaml Component", 871 | "homepage": "http://symfony.com", 872 | "time": "2013-11-26 16:40:27" 873 | } 874 | ], 875 | "aliases": [ 876 | 877 | ], 878 | "minimum-stability": "stable", 879 | "stability-flags": { 880 | "satooshi/php-coveralls": 20 881 | }, 882 | "platform": { 883 | "php": ">= 5.3" 884 | }, 885 | "platform-dev": [ 886 | 887 | ] 888 | } 889 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 18 | 19 | 20 | 21 | ./test/ 22 | 23 | 24 | 25 | 26 | 27 | ./src 28 | 29 | ./build 30 | ./composer 31 | ./test 32 | ./travis 33 | ./vendor 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/CKIPClient.php: -------------------------------------------------------------------------------- 1 | 10 | * @license No Licence 11 | * @version Release: <1.0> 12 | * @link http://fukuball@github.com 13 | */ 14 | 15 | class CKIPClient 16 | { 17 | 18 | private $server_ip; 19 | private $server_port; 20 | private $username; 21 | private $password; 22 | 23 | public $raw_text; 24 | public $return_text; 25 | public $sentence = array(); 26 | public $term = array(); 27 | 28 | /** 29 | * Method __construct initialize instance 30 | * 31 | * @return void 32 | */ 33 | public function __construct($server_ip, $server_port, $username, $password) 34 | { 35 | 36 | $this->server_ip = $server_ip; 37 | $this->server_port = $server_port; 38 | $this->username = $username; 39 | $this->password = $password; 40 | 41 | }// end function __construct 42 | 43 | /** 44 | * Method send 45 | * 46 | * @param string $raw_text 47 | * 48 | * @return string $return_text 49 | */ 50 | public function send($raw_text) 51 | { 52 | 53 | if (!empty($raw_text)) { 54 | 55 | $this->raw_text = $raw_text; 56 | 57 | $xw = new xmlWriter(); 58 | $xw->openMemory(); 59 | 60 | $xw->startDocument('1.0'); 61 | 62 | $xw->startElement('wordsegmentation'); 63 | $xw->writeAttribute('version', '0.1'); 64 | $xw->startElement('option'); 65 | $xw->writeAttribute('showcategory', '1'); 66 | $xw->endElement(); 67 | 68 | $xw->startElement('authentication'); 69 | $xw->writeAttribute('username', $this->username); 70 | $xw->writeAttribute('password', $this->password); 71 | $xw->endElement(); 72 | 73 | $xw->startElement('text'); 74 | $xw->writeRaw($this->raw_text); 75 | $xw->endElement(); 76 | 77 | $xw->endElement(); 78 | 79 | $message = iconv("utf-8", "big5", $xw->outputMemory(true)); 80 | 81 | //send message to CKIP server 82 | set_time_limit(60); 83 | 84 | $protocol = getprotobyname("tcp"); 85 | $socket = socket_create(AF_INET, SOCK_STREAM, $protocol); 86 | socket_connect($socket, $this->server_ip, $this->server_port); 87 | socket_write($socket, $message); 88 | 89 | $big5_string = ''; 90 | $buf = ''; 91 | while ($buf = socket_read($socket, 1024)) { 92 | $len = strlen($buf); 93 | if ($buf === false) { 94 | break; 95 | } 96 | $big5_string .= $buf; 97 | if ($len != 1024) { 98 | break; 99 | } 100 | } 101 | $this->return_text = iconv("big5", "utf-8", $big5_string); 102 | 103 | socket_shutdown($socket); 104 | socket_close($socket); 105 | 106 | } 107 | 108 | return $this->return_text; 109 | 110 | }// end function send 111 | 112 | /** 113 | * Method getSentence 114 | * 115 | * @return array $return_sentence 116 | */ 117 | public function getSentence() 118 | { 119 | 120 | // empty the array 121 | $this->sentence = array(); 122 | 123 | if($parse_return_text = simplexml_load_string($this->return_text)) { 124 | 125 | $sentence_array = $parse_return_text->result->sentence; 126 | 127 | foreach ($sentence_array as $key => $sentence) { 128 | 129 | $sentence_value = (string) $sentence; 130 | // remove invisible characters 131 | $check_sentence = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $sentence_value); 132 | 133 | if (!empty($check_sentence)) { 134 | array_push($this->sentence, $sentence_value); 135 | } 136 | 137 | } 138 | 139 | } 140 | 141 | return $this->sentence; 142 | 143 | }// end function getSentence 144 | 145 | /** 146 | * Method getTerm 147 | * 148 | * @return array $return_term 149 | */ 150 | public function getTerm() { 151 | 152 | // empty the array 153 | $this->term = array(); 154 | 155 | $this->getSentence(); 156 | 157 | foreach ($this->sentence as $t) { 158 | 159 | foreach (explode(" ", $t) as $s) { 160 | 161 | if ($s!="") { 162 | preg_match("/(\S*)\((\S*)\)/", $s, $m); 163 | 164 | $this_term_array = array("term"=>$m[1], "tag"=>$m[2]); 165 | array_push($this->term, $this_term_array); 166 | 167 | } 168 | 169 | } 170 | 171 | } 172 | 173 | return $this->term; 174 | 175 | }// end function getTerm 176 | 177 | /** 178 | * Method __destruct unset instance value 179 | * 180 | * @return void 181 | */ 182 | public function __destruct() 183 | { 184 | 185 | $class_property_array = get_object_vars($this); 186 | 187 | foreach ($class_property_array as $property_key => $property_value) { 188 | 189 | unset($this->$property_key); 190 | 191 | }// end foreach 192 | 193 | }// end function __destruct 194 | 195 | } 196 | ?> 197 | -------------------------------------------------------------------------------- /test/CKIPClientTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf('CKIPClient', $ckip_client_obj); 23 | 24 | } 25 | 26 | public function testDestruct() 27 | { 28 | 29 | $ckip_client_obj = new CKIPClient( 30 | CKIP_SERVER, 31 | CKIP_PORT, 32 | CKIP_USERNAME, 33 | CKIP_PASSWORD 34 | ); 35 | 36 | unset($ckip_client_obj); 37 | 38 | $ckip_client_obj = ''; 39 | 40 | $this->assertEquals(false, is_a($ckip_client_obj, 'CKIPClient')); 41 | 42 | } 43 | 44 | public function testSend() 45 | { 46 | 47 | $this->assertEquals(true, true); 48 | 49 | } 50 | 51 | public function testGetSentence() 52 | { 53 | 54 | $this->assertEquals(true, true); 55 | 56 | } 57 | 58 | public function testGetTerm() 59 | { 60 | 61 | $this->assertEquals(true, true); 62 | 63 | } 64 | 65 | 66 | } 67 | ?> -------------------------------------------------------------------------------- /test/bootstrap.php: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------