Example #1
0
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
Example #2
0
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
Example #3
0
    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")
Example #4
0
    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")