예제 #1
0
파일: app.py 프로젝트: leloulight/Twist
def classify(flag=None):
    #Pre-process tweets
    wordId,tweetId=tp.process(2)
    #TF-IDF
    docwords,docCatIds=svmp.cacheTweetsInList(wordId,tweetId,2)
    #SVM Processing
    #1. Create libSVM file
    svmp.createTestFile(docwords,docCatIds,tweetId)
    #2. Train the SVM
    if flag is not None:
        return svmp.testSVM(1)
    else:
        svmp.testSVM()
예제 #2
0
def classify():
    labels =[]
    #sampletext = request.form.get('txt1')

    wordId,tweetId=tp.process(2)
    #TF-IDF
    docwords,docCatIds=svmp.cacheTweetsInList(wordId,tweetId,2)
    #SVM Processing
    #1. Create libSVM file
    svmp.createTestFile(docwords,docCatIds,tweetId)
    #2. Train the SVM
    #svmp.trainLibLinear()
    labels = svmp.testSVM(1)
    #clean_dict(start_pos,end_pos)
    return labels