def prepareProbabilisticContext(): if not textLoader.assertContextFile("trainSet.freq"): print "no file found... Generating the probabilistic model" textClassifier.context = textClassifier.generateProbabilisticContext() textLoader.saveProbabilisticContext(textClassifier.context, "trainSet.freq") else: print "found freq. file... " textLoader.loadProbabilisticContext("trainSet.freq")
def prepareContext(): cont = {} if not textLoader.assertContextFile("trainSet.ctx"): print "from raw files" cont = textLoader.loadRaw("Christmas Carol", cont, "pg46.txt", 2000, 60) cont.update(textLoader.loadRaw("moby dick", cont, "pg2701.txt", 2000, 500)) cont.update(textLoader.loadRaw("The Prince", cont, "pg1232.txt", 2000, 100)) cont.update(textLoader.loadRaw("Beowulf", cont, "pg16328.txt", 2000, 100)) textLoader.saveContext(cont, "trainSet.ctx") else: print "from previous contexts" cont = textLoader.loadContext("trainSet.ctx") return cont
def prepareContext(): cont = {} if not textLoader.assertContextFile("trainSet.ctx"): print "from raw files" cont = textLoader.loadRaw("Christmas Carol", cont, "pg46.txt", 2000, 60) cont.update( textLoader.loadRaw("moby dick", cont, "pg2701.txt", 2000, 500)) cont.update( textLoader.loadRaw("The Prince", cont, "pg1232.txt", 2000, 100)) cont.update( textLoader.loadRaw("Beowulf", cont, "pg16328.txt", 2000, 100)) textLoader.saveContext(cont, "trainSet.ctx") else: print "from previous contexts" cont = textLoader.loadContext("trainSet.ctx") return cont