i am implementing this code and this gives me the corrent output but i want to save those four lines of"dataset" in a file and then use it.how can i do this?how can i use my own file instead of manually typed dataset?
from naiveBayesClassifier import tokenizer
from naiveBayesClassifier.trainer import Trainer
from naiveBayesClassifier.classifier import Classifier
nTrainer = Trainer(tokenizer)
dataSet =[
{'text': 'hello everyone', 'category': 'NO'},
{'text': 'dont use words like jerk', 'category': 'YES'},
{'text': 'what the hell.', 'category': 'NO'},
{'text': 'you jerk','category': 'yes'},
]
for n in dataSet:
nTrainer.train(n['text'], n['category'])
nClassifier = Classifier(nTrainer.data, tokenizer)
.
unknownInstance = "Even if I eat too much, is not it possible to lose some weight"
classification = nClassifier.classify(unknownInstance)
print classification