コード例 #1
0
def naive_bayes_demo():
    classifier = NaiveBayes.NBClassifier()

    testdata = "These are some sentences. I love writing sentences. Sometimes when I write sentences, I get sad. " \
               "I hope someday to write a sentence all on my own. Some people say that sentences are not real."

    result = []
    loss = classifier.test()
    for sentence in sent_tokenize(testdata):
        sentiment = classifier.analyzeSentiment(sentence)
        result.append(sentence + "vad" + str([x for x in sentiment]))

    print(result)
    print("loss: ", loss)