import chineseseg

segmenter = chineseseg.stanford("/home/wlzhuang/stanford-segmenter-2015-04-20/stanford-segmenter-3.5.2.jar")

print( segmenter.segment("简单调用情况如下") )

@@ -12,25 +12,28 @@
 eseseg%0A%0A
-segmenter
+%22%22%22%0Astanford
  = chine
@@ -128,43 +128,1288 @@
 r%22)%0A
-%0Aprint( segmenter.segment(%22%E7%AE%80%E5%8D%95%E8%B0%83%E7%94%A8%E6%83%85%E5%86%B5%E5%A6%82%E4%B8%8B
+print( stanford.segment(%22%E7%AE%80%E5%8D%95%E8%B0%83%E7%94%A8%E6%83%85%E5%86%B5%E5%A6%82%E4%B8%8B%22) )%0A%0A%22%22%22%0Aimport socket%0A%0Dfrom lxml.etree import tostring, fromstring%0Afrom lxml.builder import E%0Aclass Ckip():%0A%0A    CKIP_SERVER_IP, CKIP_SERVER_PORT = %22140.109.19.104%22, 1501%0A%0A    def __init__( self, username, password, server_ip = CKIP_SERVER_IP, server_port = CKIP_SERVER_PORT ):%0A        self.username = username%0A        self.password = password%0A%0A        self._server_ip = server_ip%0A        self._server_port = server_port%0A%0A    def segment( self, sent ):%0A        sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )%0A        sock.connect( (self._server_ip, self._server_port) )%0A%0A        encoding = %22big5%22%0A        tree = E.wordsegmentation(%0A            E.option(showcategory='1'),%0A            E.authentication(username=self.username, password=self.password),%0A            E.text(sent),%0A        version='0.1')%0A        xmlstring = tostring(tree, encoding=encoding, xml_declaration=True)%0A%0A%0A        sock.send( xmlstring )%0A        data = sock.recv( 10240 )%0A        sock.close()%0A        return self.parse_result( data.decode(encoding) )%0A%0A    def parse_result( self, string ):%0A        return string%0A%0A%0A%0Aseg = Ckip(%22wlzhuang%22, %22xxxxaaaackip%22)%0Aprint( seg.segment(%22%E6%9C%AC%E7%B7%9A%E4%B8%8A%E6%96%B7%E8%A9%9E%E6%9C%8D%E5%8B%99%E7%9A%84%E8%B3%87%E6%96%99%E4%BA%A4%E6%8F%9B%E6%96%B9%E5%BC%8F%E6%8E%A1%E7%94%A8%E4%B8%80XML%E6%A0%BC%E5%BC%8F%EF%BC%8C%E7%94%A8%E6%88%B6%E7%AB%AF%E5%8F%AF%E8%87%AA%E8%A1%8C%E6%92%B0%E5%AF%AB%E7%A8%8B%E5%BC%8F%E7%B6%93%E7%94%B1 TCP Socket %E9%80%A3%E7%B7%9A%E5%82%B3%E9%80%81%E9%A9%97%E8%AD%89%E8%B3%87%E8%A8%8A%E5%8F%8A%E6%96%87%E6%9C%AC%E8%87%B3%E6%9C%AC%E4%BC%BA%E6%9C%8D%E5%99%A8%EF%BC%8C%E4%BC%BA%E6%9C%8D%E5%99%A8%E7%B6%93%E9%81%8E%E8%99%95%E7%90%86%E5%BE%8C%E7%B6%93%E7%94%B1%E5%8E%9F%E9%80%A3%E7%B7%9A%E5%82%B3%E5%9B%9E%E7%B5%90%E6%9E%9C%E3%80%82%E8%AB%8B%E8%A9%B3%E9%96%B1%E4%BB%A5%E4%B8%8B%E8%AA%AA%E6%98%8E%EF%BC%9A
 %22) )

add ckip prototype