def posClassify(classes,wts,voco,testLine): global preds predict = [] testList = testLine.split() # testList = formatPOSTestInput(testLine) # for createdLine in testList: for windx in range(len(testList)): createdLine = formatPosTestInputNew(windx,testList) preds = pc.classify(classes,wts,voco,createdLine) predict.append(preds) return predict
def classify_word(cur, prev, next, g_hash): context_string = 'CUR:' + cur + ' PREV:' + prev + ' NEXT:' + next clazz = percepclassify.classify(context_string, g_hash) return clazz
def classify(question): question = preprocess(question) print('classifying') coarse_class = percepclassify.classify(question, percepclassify.get_g_hash_from_file(home+'data/models/coarse.model')) fine_class = percepclassify.classify(question, percepclassify.get_g_hash_from_file(home+'data/models/fine.'+coarse_class+'.model')) return coarse_class+':'+fine_class
def make_prediction(vdict, weights, words): windex = [vdict[word] if word in vdict else -1 for word in words] pred = percepclassify.classify(weights, windex) return words[1][5:], pred #strip the "curr:" off of the beginning
#!/usr/bin/python3 -tt import percepclassify question = input() coarse_class = percepclassify.classify(question, percepclassify.get_g_hash_from_file('../data/models/coarse.model')) fine_class = percepclassify.classify(question, percepclassify.get_g_hash_from_file('../data/models/fine.'+coarse_class+'.model')) print(coarse_class+':'+fine_class)