* Fixed notice
[lhc/web/wiklou.git] / includes / ZhClient.php
index 4f1524f..61faa8d 100644 (file)
@@ -1,10 +1,9 @@
 <?php
+
 /**
  * Client for querying zhdaemon
  *
- * @package MediaWiki
  */
-
 class ZhClient {
        var $mHost, $mPort, $mFP, $mConnected;
 
@@ -21,8 +20,6 @@ class ZhClient {
 
        /**
         * Check if connection to zhdaemon is successful
-        *
-        * @access public
         */
        function isconnected() {
                return $this->mConnected;
@@ -35,6 +32,7 @@ class ZhClient {
         */
        function connect() {
                wfSuppressWarnings();
+               $errno = $errstr = '';
                $this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30);
                wfRestoreWarnings();
                if(!$this->mFP) {
@@ -78,10 +76,9 @@ class ZhClient {
        /**
         * Convert the input to a different language variant
         *
-        * @param string $text input text
-        * @param string $tolang language variant
+        * @param $text string: input text
+        * @param $tolang string: language variant
         * @return string the converted text
-        * @access public
         */
        function convert($text, $tolang) {
                $len = strlen($text);
@@ -93,12 +90,11 @@ class ZhClient {
        }
 
        /**
-        * Convert the input to all possible variants 
+        * Convert the input to all possible variants
         *
-        * @param string $text input text
+        * @param $text string: input text
         * @return array langcode => converted_string
-        * @access public
-        */     
+        */
        function convertToAllVariants($text) {
                $len = strlen($text);
                $q = "CONV ALL $len\n$text";
@@ -112,17 +108,15 @@ class ZhClient {
                foreach($info as $variant) {
                        list($code, $len) = explode(' ', $variant);
                        $ret[strtolower($code)] = substr($data, $i, $len);
-                       $r = $ret[strtolower($code)];
                        $i+=$len;
                }
                return $ret;
-    }
+       }
        /**
         * Perform word segmentation
         *
-        * @param string $text input text
+        * @param $text string: input text
         * @return string segmented text
-        * @access public
         */
        function segment($text) {
                $len = strlen($text);
@@ -136,12 +130,8 @@ class ZhClient {
 
        /**
         * Close the connection
-        *
-        * @access public
         */
        function close() {
                fclose($this->mFP);
        }
 }
-
-?>
\ No newline at end of file