class QueryCutterTestCase(unittest.TestCase): def setUp(self): self.qc = QueryCutter("101-150", 25) def testCutResult(self): onefold, nfolds = self.qc.generate_range_pairs() self.assertEqual(cmp(onefold, ['101-125', '126-150']) , 0) self.assertEqual(cmp(nfolds, ['126-150', '101-125']) , 0)
import sys import commands import re from querycutter import QueryCutter #from termcolor import colored if (len(sys.argv) != 5): print "Help:the format is: python nFoldcrossValid.py collectionPath strategy " +\ "queryIdRange idgap" collection = sys.argv[1] allresults = collection docNums = ["5", "10", "20", "30", "50"] betas = [u"0.*"] strategy = sys.argv[2] cutter = QueryCutter(sys.argv[3], int(sys.argv[4])) #parities = ["Odd", "Even"] #parities = ["451-475","476-500"] CVIdPairs = {} oneFold, nFold = cutter.generate_range_pairs() for i in range(len(oneFold)): if nFold[i] == "151-195": nFold[i] = "151-195,201-200" CVIdPairs[nFold[i].replace(",", "")] = oneFold[i] cmds =[] for docNum in docNums: for beta in betas:
def setUp(self): self.qc = QueryCutter("101-150", 25)