Пример #1
0
def topicNum(inFile, fun):
    num = []
    if fun == 0:
        filenames = inFile
        for fname in filenames:
            data_iterator = ioFile.statFromFile(fname)
            for line in data_iterator:
                n = int(line[0])
            num.append(n)
    elif fun == 1:
        data_iterator = inFile
        for line in data_iterator:
            num.append(int(line[0]))

    return np.array(num)
Пример #2
0
def topicNum(inFile, fun):
    num = []
    if fun == 0:
        filenames = inFile
        for fname in filenames:
            data_iterator = ioFile.statFromFile(fname)
            for line in data_iterator:
                n = int(line[0])
            num.append(n)
    elif fun == 1:
        data_iterator = inFile
        for line in data_iterator:
            num.append(int(line[0]))

    return np.array(num)
Пример #3
0
        if topic_num <= 15:
            alpha = 1 / float(topic_num)
            ioFile.dataToCSV((topic_num, alpha), fname)
        while topic_num > 15:
            alpha = 1 / float(topic_num)
            ioFile.dataToCSV((topic_num, alpha), fname)
            topic_num = topic_num / 2


if __name__ == "__main__":
    optparser = OptionParser()
    optparser.add_option("-f", "--statFile", dest="input", help="fileName", default=None)
    optparser.add_option("-o", "--outputPath", dest="output", help="directory", default=None)

    (options, args) = optparser.parse_args()

    if options.input is None:
        inFile = sys.stdin
    elif options.input is not None:
        inFile = ioFile.statFromFile(options.input)
    else:
        print "No filename specified, system with exit\n"
        sys.exit("System will exit")

    if options.output is None:
        outFile = sys.stdin
    elif options.output is not None:
        outFile = options.output

    topicNum(inFile, outFile)
Пример #4
0
            topic_num = topic_num / 2


if __name__ == "__main__":
    optparser = OptionParser()
    optparser.add_option('-f', '--statFile',
                         dest='input',
                         help='fileName',
                         default=None)
    optparser.add_option('-o', '--outputPath',
                         dest='output',
                         help='directory',
                         default=None)    

    (options, args) = optparser.parse_args()
    
    if options.input is None:
            inFile = sys.stdin
    elif options.input is not None:
            inFile = ioFile.statFromFile(options.input)
    else:
            print 'No filename specified, system with exit\n'
            sys.exit('System will exit')
            
    if options.output is None:
            outFile = sys.stdin
    elif options.output is not None:
            outFile = options.output
                        
    topicNum(inFile, outFile)