Esempio n. 1
0
def get_perfo(filename):
    ''' 
    work around for using a PERL script in python
    dirty but still works.
    '''
    tempfile = str(random.randint(1, numpy.iinfo('i').max)) + '.txt'
    if not isfile(PREFIX + 'conlleval.pl'):
        download(
            'https://raw.githubusercontent.com/turian/crfchunking-with-wordrepresentations/master/scripts/conlleval.pl'
        )
        chmod('conlleval.pl', stat.S_IRWXU)  # give the execute permissions
    if len(PREFIX) > 0:
        chmod(PREFIX + 'conlleval.pl',
              stat.S_IRWXU)  # give the execute permissions
        cmd = PREFIX + 'conlleval.pl < %s | grep accuracy > %s' % (filename,
                                                                   tempfile)
    else:
        cmd = './conlleval.pl < %s | grep accuracy > %s' % (filename, tempfile)
    print cmd
    out = os.system(cmd)
    out = open(tempfile).readlines()[0].split()
    os.system('rm %s' % tempfile)
    precision = float(out[6][:-2])
    recall = float(out[8][:-2])
    f1score = float(out[10])
    return {'p': precision, 'r': recall, 'f1': f1score}
Esempio n. 2
0
def get_perfo(filename):
    ''' 
    work around for using a PERL script in python
    dirty but still works.
    '''
    tempfile = str(random.randint(1, numpy.iinfo('i').max)) + '.txt'
    if not isfile(PREFIX + 'conlleval.pl'):
        download(
            'http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl')
        chmod('conlleval.pl', stat.S_IRWXU)  # give the execute permissions
    if len(PREFIX) > 0:
        chmod(PREFIX + 'conlleval.pl',
              stat.S_IRWXU)  # give the execute permissions
        cmd = PREFIX + 'conlleval.pl < %s | grep accuracy > %s' % (filename,
                                                                   tempfile)
    else:
        cmd = './conlleval.pl < %s | grep accuracy > %s' % (filename, tempfile)
    print cmd
    out = os.system(cmd)
    out = open(tempfile).readlines()[0].split()
    os.system('rm %s' % tempfile)
    precision = float(out[6][:-2])
    recall = float(out[8][:-2])
    f1score = float(out[10])
    return {'p': precision, 'r': recall, 'f1': f1score}
Esempio n. 3
0
def get_perf(filename):
    ''' run conlleval.pl perl script to obtain
    precision/recall and F1 score '''
    _conlleval = PREFIX + 'conlleval.pl'
    if not isfile(_conlleval):
        # download('http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl')
        download(
            'https://raw.githubusercontent.com/turian/crfchunking-with-wordrepresentations/master/scripts/conlleval.pl'
        )
        chmod('conlleval.pl', stat.S_IRWXU)  # give the execute permissions

    proc = subprocess.Popen(["perl", _conlleval],
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE)
    stdout, _ = proc.communicate(open(filename).read())
    for line in stdout.split('\n'):
        if 'accuracy' in line:
            out = line.split()
            break

    precision = float(out[3][:-2])
    recall = float(out[5][:-2])
    f1score = float(out[7])

    return {'p': precision, 'r': recall, 'f1': f1score}
Esempio n. 4
0
def get_perf(filename):
    ''' run conlleval.pl perl script to obtain
    precision/recall and F1 score '''
    _conlleval = PREFIX + 'conlleval.pl'
    if not isfile(_conlleval):
        download('http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl') 
        chmod('conlleval.pl', stat.S_IRWXU) # give the execute permissions

    proc = subprocess.Popen(["perl", _conlleval], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    stdout, _ = proc.communicate(open(filename).read())
    for line in stdout.split('\n'):
        if 'accuracy' in line:
            out = line.split()
            break
    
    precision = float(out[6][:-2])
    recall    = float(out[8][:-2])
    f1score   = float(out[10])

    return {'p':precision, 'r':recall, 'f1':f1score}
Esempio n. 5
0
def get_perf(filename):
    ''' run conlleval.pl perl script to obtain
    precision/recall and F1 score '''
    _conlleval = PREFIX + 'conlleval.pl'
    if not isfile(_conlleval):
        # download('http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl')
        download('https://raw.githubusercontent.com/turian/crfchunking-with-wordrepresentations/master/scripts/conlleval.pl')
        chmod('conlleval.pl', stat.S_IRWXU) # give the execute permissions

    proc = subprocess.Popen(["perl", _conlleval], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    stdout, _ = proc.communicate(open(filename).read())
    for line in stdout.split('\n'):
        if 'accuracy' in line:
            out = line.split()
            break
    
    precision = float(out[3][:-2])
    recall    = float(out[5][:-2])
    f1score   = float(out[7])

    return {'p':precision, 'r':recall, 'f1':f1score}
Esempio n. 6
0
def get_perfo(filename):
    """ 
    work around for using a PERL script in python
    dirty but still works.
    """
    tempfile = str(random.randint(1, numpy.iinfo("i").max)) + ".txt"
    if not isfile(PREFIX + "conlleval.pl"):
        download("http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl")
        chmod("conlleval.pl", stat.S_IRWXU)  # give the execute permissions
    if len(PREFIX) > 0:
        chmod(PREFIX + "conlleval.pl", stat.S_IRWXU)  # give the execute permissions
        cmd = PREFIX + "conlleval.pl < %s | grep accuracy > %s" % (filename, tempfile)
    else:
        cmd = "./conlleval.pl < %s | grep accuracy > %s" % (filename, tempfile)
    print cmd
    out = os.system(cmd)
    out = open(tempfile).readlines()[0].split()
    os.system("rm %s" % tempfile)
    precision = float(out[6][:-2])
    recall = float(out[8][:-2])
    f1score = float(out[10])
    return {"p": precision, "r": recall, "f1": f1score}
Esempio n. 7
0
def get_perfo(filename):
    ''' 
    work around for using a PERL script in python
    dirty but still works.
    '''
    tempfile = str(random.randint(1,numpy.iinfo('i').max)) + '.txt'
    if not isfile(PREFIX + 'conlleval.pl'):
        download('http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl') 
        chmod('conlleval.pl', stat.S_IRWXU) # give the execute permissions
    if len(PREFIX) > 0:
        chmod(PREFIX + 'conlleval.pl', stat.S_IRWXU) # give the execute permissions
        cmd = PREFIX + 'conlleval.pl < %s | grep accuracy > %s'%(filename,tempfile)
    else:
        cmd = './conlleval.pl < %s | grep accuracy > %s'%(filename,tempfile)
    print cmd
    out = os.system(cmd)
    out = open(tempfile).readlines()[0].split()
    os.system('rm %s'%tempfile)
    precision = float(out[6][:-2])
    recall    = float(out[8][:-2])
    f1score   = float(out[10])
    return {'p':precision, 'r':recall, 'f1':f1score}
Esempio n. 8
0
def get_perfo(filename):
    ''' 
    work around for using a PERL script in python
    dirty but still works.
    '''
    tempfile = str(random.randint(1,numpy.iinfo('i').max)) + '.txt'
    if not isfile(PREFIX + 'conlleval.pl'):
        download('https://raw.githubusercontent.com/turian/crfchunking-with-wordrepresentations/master/scripts/conlleval.pl')
        chmod('conlleval.pl', stat.S_IRWXU) # give the execute permissions
    if len(PREFIX) > 0:
        chmod(PREFIX + 'conlleval.pl', stat.S_IRWXU) # give the execute permissions
        cmd = PREFIX + 'conlleval.pl < %s | grep accuracy > %s'%(filename,tempfile)
    else:
        cmd = './conlleval.pl < %s | grep accuracy > %s'%(filename,tempfile)
    print cmd
    out = os.system(cmd)
    out = open(tempfile).readlines()[0].split()
    os.system('rm %s'%tempfile)
    precision = float(out[6][:-2])
    recall    = float(out[8][:-2])
    f1score   = float(out[10])
    return {'p':precision, 'r':recall, 'f1':f1score}
Esempio n. 9
0
def get_perf(filename):
    ''' run conlleval.pl perl script to obtain
    precision/recall and F1 score '''
    _conlleval = PREFIX + 'conlleval.pl'
    if not isfile(_conlleval):
        download(
            'http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl')
        chmod('conlleval.pl', stat.S_IRWXU)  # give the execute permissions

    proc = subprocess.Popen(["perl", _conlleval],
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE)
    stdout, _ = proc.communicate(open(filename).read())
    for line in stdout.split('\n'):
        if 'accuracy' in line:
            out = line.split()
            break

    precision = float(out[6][:-2])
    recall = float(out[8][:-2])
    f1score = float(out[10])

    return {'p': precision, 'r': recall, 'f1': f1score}