Class: CnTelecomeSeg::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/189seg/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(apid, key, product_id) ⇒ Base

Returns a new instance of Base.



3
4
5
6
7
# File 'lib/189seg/base.rb', line 3

def initialize(apid, key, product_id)
  @apid = apid
  @key = key
  @product_id = product_id
end

Instance Method Details

#segment(phrase) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/189seg/base.rb', line 9

def segment(phrase)
  api_url = 'http://125.64.11.43:8080/udt-see/StartServiceServlet'
  params = init_params
  params['params']['DivideText'] = phrase
  response = RestClient.post api_url, encode_json(params), :content_type => :json, :accept => :json
  decoded_response = decode_json(response.to_s)
  decoded_response
end