summaryrefslogtreecommitdiff
path: root/includes/ZhClient.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/ZhClient.php')
-rw-r--r--includes/ZhClient.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/includes/ZhClient.php b/includes/ZhClient.php
index 61faa8df..a04220c6 100644
--- a/includes/ZhClient.php
+++ b/includes/ZhClient.php
@@ -12,7 +12,7 @@ class ZhClient {
*
* @access private
*/
- function ZhClient($host, $port) {
+ function __construct($host, $port) {
$this->mHost = $host;
$this->mPort = $port;
$this->mConnected = $this->connect();
@@ -35,7 +35,7 @@ class ZhClient {
$errno = $errstr = '';
$this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30);
wfRestoreWarnings();
- if(!$this->mFP) {
+ if ( !$this->mFP ) {
return false;
}
return true;
@@ -47,8 +47,9 @@ class ZhClient {
* @access private
*/
function query($request) {
- if(!$this->mConnected)
+ if ( !$this->mConnected ) {
return false;
+ }
fwrite($this->mFP, $request);
@@ -68,8 +69,9 @@ class ZhClient {
$data .= $str;
}
//data should be of length $len. otherwise something is wrong
- if(strlen($data) != $len)
+ if ( strlen($data) != $len ) {
return false;
+ }
return $data;
}
@@ -84,8 +86,9 @@ class ZhClient {
$len = strlen($text);
$q = "CONV $tolang $len\n$text";
$result = $this->query($q);
- if(!$result)
+ if ( !$result ) {
$result = $text;
+ }
return $result;
}
@@ -99,8 +102,9 @@ class ZhClient {
$len = strlen($text);
$q = "CONV ALL $len\n$text";
$result = $this->query($q);
- if(!$result)
+ if ( !$result ) {
return false;
+ }
list($infoline, $data) = explode('|', $result, 2);
$info = explode(";", $infoline);
$ret = array();
@@ -122,8 +126,8 @@ class ZhClient {
$len = strlen($text);
$q = "SEG $len\n$text";
$result = $this->query($q);
- if(!$result) {// fallback to character based segmentation
- $result = ZhClientFake::segment($text);
+ if ( !$result ) {// fallback to character based segmentation
+ $result = $this->segment($text);
}
return $result;
}