ckip_client 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.md +3 -3
  2. data/lib/CKIP_Client.rb +12 -6
  3. metadata +3 -3
data/README.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  [RubyGems](http://rubygems.org/gems/ckip_client)
4
4
 
5
- CKIP_CLient是連接[中央研究院][中央研究院][詞庫小組][詞庫小組]研發之[中文斷詞系統][斷詞系統]與[中文剖析系統][剖析系統]的Ruby程式界面。
5
+ CKIP_Client是連接[中央研究院][中央研究院][詞庫小組][詞庫小組]研發之[中文斷詞系統][斷詞系統]與[中文剖析系統][剖析系統]的Ruby程式界面。
6
6
  感謝中央研究院[詞庫小組][詞庫小組]多年來之研究成果!
7
7
 
8
8
 
9
9
  ## 安裝 Installation
10
10
 
11
11
  請先至中文斷詞系統[網站][斷詞申請]或中文剖析系統[網站][剖析申請]申請:帳號/密碼
12
- 再安裝本Gem
12
+ 再安裝本Gem
13
13
 
14
14
  gem install chinese_convt
15
15
 
@@ -38,7 +38,7 @@ CKIP_CLient是連接[中央研究院][中央研究院][詞庫小組][詞庫小
38
38
 
39
39
  注:
40
40
  輸入的字串編碼可以是 UTF-8 或是 Big5 或 Big5-UAO 三種其中之一。
41
- 但是輸出結果一律為 UTF-8 編碼!
41
+ 但是輸出結果一律為 UTF-8 編碼。
42
42
 
43
43
 
44
44
  ## 範例 Example
data/lib/CKIP_Client.rb CHANGED
@@ -20,12 +20,18 @@ module CKIP
20
20
  <authentication username=\"#{config['username']}\" password=\"#{config['password']}\" />
21
21
  <text>#{text}</text>
22
22
  </wordsegmentation>"
23
-
24
- socket = TCPSocket.open( config['host'] , config['port'] )
25
- socket.write( request )
26
- xml_result = socket.gets.force_encoding( text_encoding )
27
- socket.close
28
- return xml_result
23
+ begin
24
+ Timeout::timeout(5) {
25
+ socket = TCPSocket.open( config['host'] , config['port'] )
26
+ socket.write( request )
27
+ xml_result = socket.gets.force_encoding( text_encoding )
28
+ socket.close
29
+ return xml_result
30
+ }
31
+ rescue Timeout::Error
32
+ puts "CKIP Connection Timeout!!!"
33
+ raise Timeout::Error
34
+ end
29
35
  end
30
36
 
31
37
  def self.xml2str( xml )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ckip_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,9 +9,9 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: CKIP_CLient是連接中央研究院詞庫小組研發之中文斷詞系統與中文剖析系統的Ruby程式界面。感謝中央研究院[詞庫小組][詞庫小組]多年來之研究成果!
14
+ description: CKIP_CLient是連接中央研究院詞庫小組研發之中文斷詞系統與中文剖析系統的Ruby程式界面。感謝中央研究院詞庫小組多年來之研究成果!
15
15
  email: xxxooo.tw@gmail.com
16
16
  executables: []
17
17
  extensions: []