def nerLearn(ner_formatted_trainList,ner_model_file): ALPHA = 1.0 EPOCH = 10 trainNERList = ner_formatted_trainList vocabulary,classes,trainSize = learn.createVocabulary(trainNERList) nerWeights = learn.initWeights(vocabulary,classes) nerCache = learn.initWeights(vocabulary,classes) ner_avg_weights = learn.initWeights(vocabulary,classes) nerModel = learn.learn(vocabulary,nerWeights,nerCache,ner_avg_weights,trainNERList,trainSize,ALPHA,EPOCH) learn.writeModel(nerModel,vocabulary,ner_model_file)
def posLearn(pos_format_trainList,pos_model_file): ALPHA = 1.0 EPOCH = 5 trainPOSList = pos_format_trainList random.shuffle(trainPOSList) vocabulary,classes,trainSize = learn.createVocabulary(trainPOSList) posWeights = learn.initWeights(vocabulary,classes) posCache = learn.initWeights(vocabulary,classes) pos_avg_weights = learn.initWeights(vocabulary,classes) posModel = learn.learn(vocabulary,posWeights,posCache,pos_avg_weights,trainPOSList,trainSize,ALPHA,EPOCH) learn.writeModel(posModel,vocabulary,pos_model_file)