コード例 #1
0
from NaiveBayes import Pool
import os

# https://www.python-course.eu/text_classification_python.php
# https://www.youtube.com/watch?v=BJ-VvGyQxho
DClasses = ["clinton", "lawyer", "math", "medical", "music", "sex"]

base = "learn/"
p = Pool()
for i in DClasses:
    p.learn(base + i, i)

base = "test/"
for i in DClasses:
    dir = os.listdir(base + i)
    for file in dir:
        res = p.Probability(base + i + "/" + file)
        print(i + ": " + file + ": " + str(res))
コード例 #2
0
ファイル: bclass2.py プロジェクト: bshikhar13/Emulsifier
filename = 'testing.txt'
target = open(filename, 'w')
target.write(content)
target.close()

print("f**k")

print("yoyo" + content)

DClasses = [
    "achievement_striving", "adventurousness", "artistic_interest",
    "assertiveness", "cautiousness", "cheerfulness", "dutifulness",
    "emotionality", "excitement_seeker", "friendliness", "gregariousness",
    "imagination", "intellect", "liberalism", "orderliness", "self_discipline",
    "self_efficacy", "trust", "activity_level", "altruism", "anger", "anxiety",
    "cooperation", "depression", "self_consciousness", "immoderation",
    "modesty", "morality", "sympathy", "vulnerability"
]

base = "learn/"
p = Pool()
for i in DClasses:
    p.learn(base + i, i)

base = "test/"

print("I am in class !! ")
res = p.Probability(filename)
print(str(res))
print("\nIamhero\n")