<?php
-/**
- * @package MediaWiki
- */
/**
* Client for querying zhdaemon
*
- * @package MediaWiki
*/
class ZhClient {
var $mHost, $mPort, $mFP, $mConnected;
/**
* Check if connection to zhdaemon is successful
- *
- * @access public
*/
function isconnected() {
return $this->mConnected;
*/
function connect() {
wfSuppressWarnings();
+ $errno = $errstr = '';
$this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30);
wfRestoreWarnings();
if(!$this->mFP) {
/**
* 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);
/**
* 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);
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);
/**
* Close the connection
- *
- * @access public
*/
function close() {
fclose($this->mFP);
}
}
-?>
\ No newline at end of file