Example #1
0
def token_type(disc_clsdict, wrd_corpus, 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)

    with open(path.join(dest, 'token_type'), 'w') as fid:
        fid.write(pretty_score(ptoc, rtoc, ftoc, 'token total',
                                 sum(map(len, fragments_cross))))
        fid.write('\n')
        fid.write(pretty_score(ptyc, rtyc, ftyc, 'type total',
                                 sum(map(len, fragments_cross))))
Example #2
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))))
Example #3
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))))