def __init__(self, model_path): self.identifer = libtrate.DoubleIdentifer() self.identifer.Load(model_path + '/identifer.bin') self.predictor = Predictor() self.predictor.load(model_path) self.normalizer = libnormalizer.NormalizerFactory().Load(model_path + '/normalizer.bin') from libcalibrator import CalibratorFactory self.calibrator = CalibratorFactory.Load(model_path + '/calibrator.bin') Segmentor.Init()
def __init__(self, model_path, predictor_path): self.identifer = libtrate.DoubleIdentifer() self.identifer.Load(model_path + '/identifer.bin') #self.predictor = libtrate.LinearPredictor() #self.predictor.Load(predictor_path) self.predictor = libtrate.PredictorFactory.LoadPredictor( predictor_path) self.dnn_predictor = DnnPredictor() self.dnn_predictor.load(model_path) self.normalizer = None if self.predictor == None: self.normalizer = libnormalizer.NormalizerFactory().Load( './normalizer.bin') else: self.normalizer = self.predictor.GetNormalizer() from libcalibrator import CalibratorFactory self.calibrator = CalibratorFactory.Load(model_path + '/calibrator.bin') Segmentor.Init()
#pid = 82069969465 pid = 82069968445 pid = 82073369485 pid = 82154598133 info = libtieba.get_post_info(pid) print info.title, ' ', info.content import libtrate identifer = libtrate.DoubleIdentifer() #identifer.Load('./data/ltrate.thread.model/identifer.bin') identifer.Load('./ltrate.thread.model/identifer.bin') print identifer.size() print identifer.id('工程') #normalizer = libtrate.NormalizerFactory.CreateNormalizer('minmax', './data/ltrate.thread.model/normalizer.bin') #normalizer = libnormalizer.NormalizerFactory.Load('./data/ltrate.thread.model/normalizer.bin') normalizer = libnormalizer.NormalizerFactory.Load('./ltrate.thread.model/normalizer.bin') #lpredictor = libtrate.PredictorFactory.LoadPredictor('./data/ltrate.thread.model/') lpredictor = libtrate.PredictorFactory.LoadPredictor('./ltrate.thread.model/') from libcalibrator import CalibratorFactory calibrator = CalibratorFactory.Load('./model/calibrator.bin')