Skip to content

Instantly share code, notes, and snippets.

@odasatoshi
Created March 26, 2012 01:34
Show Gist options
  • Save odasatoshi/2202110 to your computer and use it in GitHub Desktop.
Save odasatoshi/2202110 to your computer and use it in GitHub Desktop.
correct python client
import classifier_types
import msgpackrpc
class classifier:
def __init__ (self, host, port):
address = msgpackrpc.Address(host, port)
self.client = msgpackrpc.Client(address)
def set_config (self, arg0, arg1):
arg0 = arg0
arg1 = arg1.to_array()
return self.client.call('set_config', arg0, arg1)
def get_config (self, arg0, arg1):
arg0 = arg0
arg1 = arg1
return self.client.call('get_config', arg0, arg1)
def train (self, arg0, arg1):
arg0 = arg0
arg1 = [(lab, elem.to_array()) for lab, elem in arg1]
return self.client.call('train', arg0, arg1)
def classify (self, arg0, arg1):
arg0 = arg0
arg1 = [elem.to_array() for elem in arg1]
return self.client.call('classify', arg0, arg1)
def save (self, arg0, arg1):
arg0 = arg0
arg1 = arg1
return self.client.call('save', arg0, arg1)
def load (self, arg0, arg1):
arg0 = arg0
arg1 = arg1
return self.client.call('load', arg0, arg1)
def get_status (self, arg0, arg1):
arg0 = arg0
arg1 = arg1
return self.client.call('get_status', arg0, arg1)
#/usr/bin/python
# -*- coding:utf-8 -*-
# This file is auto-generated from TYPES
# *** DO NOT EDIT ***
import sys
import msgpack
class string_rule:
def __init__(self, key, type, sample_weight, global_weight):
self.key = key
self.type = type
self.sample_weight = sample_weight
self.global_weight = global_weight
def to_array(self):
variables = []
variables.append(self.key)
variables.append(self.type)
variables.append(self.sample_weight)
variables.append(self.global_weight)
return variables
class filter_rule:
def __init__(self, key, type, suffix):
self.key = key
self.type = type
self.suffix = suffix
def to_array(self):
variables = []
variables.append(self.key)
variables.append(self.type)
variables.append(self.suffix)
return variables
class num_rule:
def __init__(self, key, type):
self.key = key
self.type = type
def to_array(self):
variables = []
variables.append(self.key)
variables.append(self.type)
return variables
class converter_config:
def __init__(self, string_filter_types, string_filter_rules, num_filter_types, num_filter_rules, string_types, string_rules, num_types, num_rules):
self.string_filter_types = string_filter_types
self.string_filter_rules = string_filter_rules
self.num_filter_types = num_filter_types
self.num_filter_rules = num_filter_rules
self.string_types = string_types
self.string_rules = string_rules
self.num_types = num_types
self.num_rules = num_rules
def to_array(self):
variables = []
variables.append(self.string_filter_types)
variables.append([elem.to_array() for elem in self.string_filter_rules])
variables.append(self.num_filter_types)
variables.append([elem.to_array() for elem in self.num_filter_rules])
variables.append(self.string_types)
variables.append([elem.to_array() for elem in self.string_rules])
variables.append(self.num_types)
variables.append([elem.to_array() for elem in self.num_rules])
return variables
class config_data:
def __init__(self, method, config):
self.method = method
self.config = config
def to_array(self):
variables = []
variables.append(self.method)
variables.append(self.config.to_array())
return variables
class datum:
def __init__(self, sv, nv):
self.sv = sv
self.nv = nv
def to_array(self):
variables = (self.sv, self.nv)
return variables
class estimate_result:
def __init__(self, label, prob):
self.label = label
self.prob = prob
def to_array(self):
variables = []
variables.append(self.label)
variables.append(self.prob)
return variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment