示例#1
0
def token_type(disc_clsdict, wrd_corpus, fragments_within, fragments_cross,
               dest, verbose, n_jobs):
    if verbose:
        print banner('TOKEN/TYPE')
    ptoc, rtoc, ptyc, rtyc = _token_type_sub(disc_clsdict, wrd_corpus,
                                             fragments_cross, 'cross',
                                             verbose, n_jobs)
    ftoc = np.fromiter((fscore(ptoc[i], rtoc[i]) for i in xrange(ptoc.shape[0])),
                       dtype=np.double)
    ftyc = np.fromiter((fscore(ptyc[i], rtyc[i]) for i in xrange(ptyc.shape[0])),
                       dtype=np.double)

    ptow, rtow, ptyw, rtyw = _token_type_sub(disc_clsdict, wrd_corpus,
                                             fragments_within, 'within',
                                             verbose, n_jobs)
    ftow = np.fromiter((fscore(ptow[i], rtow[i]) for i in xrange(ptow.shape[0])),
                       dtype=np.double)
    ftyw = np.fromiter((fscore(ptyw[i], rtyw[i]) for i in xrange(rtyw.shape[0])),
                       dtype=np.double)
    with open(path.join(dest, 'token_type'), 'w') as fid:
        fid.write(pretty_score_f(ptoc, rtoc, ftoc, 'token total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(ptyc, rtyc, ftyc, 'type total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(ptow, rtow, ftow, 'token within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
        fid.write('\n')
        fid.write(pretty_score_f(ptyw, rtyw, ftyw, 'type within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
示例#2
0
def token_type(disc_clsdict, wrd_corpus, fragments_within, fragments_cross,
               dest, verbose, n_jobs):
    if verbose:
        print banner('TOKEN/TYPE')
    ptoc, rtoc, ptyc, rtyc = _token_type_sub(disc_clsdict, wrd_corpus,
                                             fragments_cross, 'cross',
                                             verbose, n_jobs)
    ftoc = np.fromiter((fscore(ptoc[i], rtoc[i]) for i in xrange(ptoc.shape[0])),
                       dtype=np.double)
    ftyc = np.fromiter((fscore(ptyc[i], rtyc[i]) for i in xrange(ptyc.shape[0])),
                       dtype=np.double)

    ptow, rtow, ptyw, rtyw = _token_type_sub(disc_clsdict, wrd_corpus,
                                             fragments_within, 'within',
                                             verbose, n_jobs)
    ftow = np.fromiter((fscore(ptow[i], rtow[i]) for i in xrange(ptow.shape[0])),
                       dtype=np.double)
    ftyw = np.fromiter((fscore(ptyw[i], rtyw[i]) for i in xrange(rtyw.shape[0])),
                       dtype=np.double)
    with open(path.join(dest, 'token_type'), 'w') as fid:
        fid.write(pretty_score_f(ptoc, rtoc, ftoc, 'token total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(ptyc, rtyc, ftyc, 'type total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(ptow, rtow, ftow, 'token within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
        fid.write('\n')
        fid.write(pretty_score_f(ptyw, rtyw, ftyw, 'type within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
示例#3
0
def group(disc_clsdict, fragments_within, fragments_cross, dest, verbose, n_jobs):
    if verbose:
        print banner('GROUP')
    pc, rc = _group_sub(disc_clsdict, fragments_cross, 'cross', verbose, n_jobs)
    fc = np.fromiter((fscore(pc[i], rc[i]) for i in xrange(pc.shape[0])), dtype=np.double)

    pw, rw = _group_sub(disc_clsdict, fragments_within, 'within', verbose, n_jobs)
    fw = np.fromiter((fscore(pw[i], rw[i]) for i in xrange(pw.shape[0])), dtype=np.double)
    with open(path.join(dest, 'group'), 'w') as fid:
        fid.write(pretty_score_f(pc, rc, fc, 'group total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(pw, rw, fw, 'group within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
示例#4
0
def group(disc_clsdict, fragments_within, fragments_cross, dest, verbose, n_jobs):
    if verbose:
        print banner('GROUP')
    pc, rc = _group_sub(disc_clsdict, fragments_cross, 'cross', verbose, n_jobs)
    fc = np.fromiter((fscore(pc[i], rc[i]) for i in xrange(pc.shape[0])), dtype=np.double)

    pw, rw = _group_sub(disc_clsdict, fragments_within, 'within', verbose, n_jobs)
    fw = np.fromiter((fscore(pw[i], rw[i]) for i in xrange(pw.shape[0])), dtype=np.double)
    with open(path.join(dest, 'group'), 'w') as fid:
        fid.write(pretty_score_f(pc, rc, fc, 'group total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(pw, rw, fw, 'group within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
示例#5
0
def boundary_wrd(disc_clsdict, corpus, fragments_within, fragments_cross,
                 dest, verbose, n_jobs, threshold=0.03):
    if verbose:
        print banner('BOUNDARY (WRD)')
    pc, rc = _boundary_sub(disc_clsdict, corpus, fragments_cross,
                           'cross', verbose, n_jobs, threshold=threshold)
    fc = np.fromiter((fscore(pc[i], rc[i]) for i in xrange(pc.shape[0])), dtype=np.double)
    pw, rw = _boundary_sub(disc_clsdict, corpus, fragments_within,
                           'within', verbose, n_jobs, threshold=threshold)
    fw = np.fromiter((fscore(pw[i], rw[i]) for i in xrange(pw.shape[0])), dtype=np.double)
    with open(path.join(dest, 'boundary_wrd'), 'w') as fid:
        fid.write(pretty_score_f(pc, rc, fc, 'boundary total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(pw, rw, fw, 'boundary within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
示例#6
0
def boundary(disc_clsdict, corpus, fragments_cross,
               dest, verbose, n_jobs):
    if verbose:
        print banner('BOUNDARY')
    pc, rc = _boundary_sub(disc_clsdict, corpus, fragments_cross,
                           'cross', verbose, n_jobs)
    fc = np.fromiter((fscore(pc[i], rc[i]) for i in xrange(pc.shape[0])), dtype=np.double)
    with open(path.join(dest, 'boundary'), 'w') as fid:
        fid.write(pretty_score(pc, rc, fc, 'boundary total',
                                 sum(map(len, fragments_cross))))
示例#7
0
def match(disc_clsdict, gold_clsdict, phn_corpus,
          fragments_within, fragments_cross,
          dest, verbose, n_jobs):
    if verbose:
        print banner('MATCHING')
    pc, rc = _match_sub(disc_clsdict, gold_clsdict, phn_corpus,
                        fragments_cross, 'cross', verbose, n_jobs)
    fc = np.fromiter((fscore(pc[i], rc[i]) for i in xrange(pc.shape[0])), dtype=np.double)

    pw, rw = _match_sub(disc_clsdict, gold_clsdict, phn_corpus,
                        fragments_within, 'within', verbose, n_jobs)
    fw = np.fromiter((fscore(pw[i], rw[i]) for i in xrange(pw.shape[0])), dtype=np.double)
    with open(path.join(dest, 'matching'), 'w') as fid:
        fid.write(pretty_score_f(pc, rc, fc, 'match total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(pw, rw, fw, 'match within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
示例#8
0
def match(disc_clsdict, gold_clsdict, phn_corpus,
          fragments_within, fragments_cross,
          dest, verbose, n_jobs):
    if verbose:
        print banner('MATCHING')
    pc, rc = _match_sub(disc_clsdict, gold_clsdict, phn_corpus,
                        fragments_cross, 'cross', verbose, n_jobs)
    fc = np.fromiter((fscore(pc[i], rc[i]) for i in xrange(pc.shape[0])), dtype=np.double)

    pw, rw = _match_sub(disc_clsdict, gold_clsdict, phn_corpus,
                        fragments_within, 'within', verbose, n_jobs)
    fw = np.fromiter((fscore(pw[i], rw[i]) for i in xrange(pw.shape[0])), dtype=np.double)
    with open(path.join(dest, 'matching'), 'w') as fid:
        fid.write(pretty_score_f(pc, rc, fc, 'match total',
                                 len(fragments_cross),
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score_f(pw, rw, fw, 'match within-speaker only',
                                 len(fragments_within),
                                 sum(map(len, fragments_within))))
示例#9
0
def group(disc_clsdict, fragments_all, dest, verbose, n_jobs):
    if verbose:
        print banner('GROUP')
    #TODO CHECK SCORE ACROSS/WITHIN!
    pc, rc = _group_sub(disc_clsdict, fragments_all, 'all', verbose, n_jobs)
    fc = np.fromiter((fscore(pc[i], rc[i]) for i in xrange(pc.shape[0])), dtype=np.double)

    #pw, rw = _group_sub(disc_clsdict, fragments_within, 'within', verbose, n_jobs)
    #fw = np.fromiter((fscore(pw[i], rw[i]) for i in xrange(pw.shape[0])), dtype=np.double)
    with open(path.join(dest, 'group'), 'w') as fid:
        fid.write(pretty_score(pc, rc, fc, 'group total',
                                 sum(map(len, fragments_all))))