示例#1
0
文件: cca.py 项目: karlstratos/cca
def main(args):
    set_quiet(args.quiet)
    
    if args.corpus: 
        unigrams = count_unigrams(args.corpus)
        vocab, outfname = decide_vocab(unigrams, args.cutoff, 
                                       args.vocab, args.want)
        if args.rewrite: 
            rewrite_corpus(args.corpus, vocab, outfname)
        else:
            extract_stat(args.corpus, vocab, outfname, args.window)
    
    if args.stat:
        assert(args.m is not None and args.kappa is not None)
        if args.no_matlab:        
            C = canon()
            C.set_params(args.m, args.kappa)     
            C.get_stat(args.stat)
            C.start_logging()
            C.approx_cca()
            C.end_logging()
            C.write_result()
        else:
            call_matlab(args.stat, args.m, args.kappa)
        
    if args.clean: clean()
示例#2
0
def main(args):
    set_quiet(args.quiet)

    if args.corpus:
        unigrams = count_unigrams(args.corpus)
        vocab, outfname = decide_vocab(unigrams, args.cutoff, args.vocab,
                                       args.want)
        if args.rewrite:
            rewrite_corpus(args.corpus, vocab, outfname)
        else:
            extract_stat(args.corpus, vocab, outfname, args.window)

    if args.stat:
        assert (args.m is not None and args.kappa is not None)
        if args.no_matlab:
            C = canon()
            C.set_params(args.m, args.kappa)
            C.get_stat(args.stat)
            C.start_logging()
            C.approx_cca()
            C.end_logging()
            C.write_result()
        else:
            call_matlab(args.stat, args.m, args.kappa)

    if args.clean: clean()
示例#3
0
文件: debug.py 项目: karlstratos/cca
def check():
    unigrams = count_unigrams(corpus)
    vocab, outfname = decide_vocab(unigrams, cutoff, None, None)
    XYcount, Xcount, Ycount, stat = extract_stat(corpus, vocab, 
                                                 outfname, window)
    for x in Xcount: assert(Xcount[x] == gold_Xcount[x])
    for y in Ycount: assert(Ycount[y] == gold_Ycount[y])
    for x, y in XYcount: assert(XYcount[x,y] == gold_XYcount[x,y])
    return stat 
示例#4
0
def check():
    unigrams = count_unigrams(corpus)
    vocab, outfname = decide_vocab(unigrams, cutoff, None, None)
    XYcount, Xcount, Ycount, stat = extract_stat(corpus, vocab, outfname,
                                                 window)
    for x in Xcount:
        assert (Xcount[x] == gold_Xcount[x])
    for y in Ycount:
        assert (Ycount[y] == gold_Ycount[y])
    for x, y in XYcount:
        assert (XYcount[x, y] == gold_XYcount[x, y])
    return stat