def train(): print "def train():" textClassifier.context = prepareContext() probabilities.context = textClassifier.splitContext() x = OrderedDict(sorted(probabilities.classify("A pile on the earth strong for the burning".split()).iteritems(),key=operator.itemgetter(1),reverse=True)) print "probabilities.maxLikelyHood(x) = ",probabilities.maxLikelyHood(x) print x
def train(): print "def train():" textClassifier.context = prepareContext() probabilities.context = textClassifier.splitContext() x = OrderedDict( sorted(probabilities.classify( "A pile on the earth strong for the burning".split()).iteritems(), key=operator.itemgetter(1), reverse=True)) print "probabilities.maxLikelyHood(x) = ", probabilities.maxLikelyHood(x) print x
probabilities.context = textClassifier.splitContext() x = OrderedDict( sorted(probabilities.classify( "A pile on the earth strong for the burning".split()).iteritems(), key=operator.itemgetter(1), reverse=True)) print "probabilities.maxLikelyHood(x) = ", probabilities.maxLikelyHood(x) print x if __name__ == '__main__': for i in TO_RUN: if i and basic: runBasics() if i and train: train() if i and info: print "prepare " textClassifier.raw_context = prepareContext() print "splitting " textClassifier.raw_context = textClassifier.splitContext() probabilities.context = textClassifier.raw_context print "generating probabilities " prepareProbabilisticContext() print "dumping " textClassifier.contextInfo() # print textClassifier.context print "Text Classify test " print "The register of his burial was signed by the clergyman, the clerk, the undertaker" # print "",textClassifier.classify("goose")
textClassifier.context = prepareContext() probabilities.context = textClassifier.splitContext() x = OrderedDict(sorted(probabilities.classify("A pile on the earth strong for the burning".split()).iteritems(),key=operator.itemgetter(1),reverse=True)) print "probabilities.maxLikelyHood(x) = ",probabilities.maxLikelyHood(x) print x if __name__ == '__main__': for i in TO_RUN: if i and basic: runBasics() if i and train: train() if i and info: print "prepare " textClassifier.raw_context = prepareContext() print "splitting " textClassifier.raw_context = textClassifier.splitContext() probabilities.context = textClassifier.raw_context print "generating probabilities " prepareProbabilisticContext() print "dumping " textClassifier.contextInfo() # print textClassifier.context print "Text Classify test " print "The register of his burial was signed by the clergyman, the clerk, the undertaker" # print "",textClassifier.classify("goose")