Пример #1
0
def test():
    for name in filenames:
        print('Processing ' + name + '...')
        print('Actual || Expected || % Accuracy || isFlagged')
        
        diff = []

        # Process each image
        actual = script.process(name)
        with open('./expected/' + name + '.txt', 'r') as f:
            expected = f.read().strip().split('\n')

        # Calculate % accuracy
        for i in xrange(len(expected)):
            aline = actual[i][0]
            flagged = actual[i][3]
            eline = expected[i].strip()
            # ignore unnecessary lines eg. address
            if(eline.startswith('!')):
                continue

            acc = fuzz.ratio(aline, eline)
            diff.append(acc)
            print ' || '.join((aline, eline, str(acc), flagged))

        # average accuracy across all lines
        total = reduce(lambda x, y: x+y, diff)
        avg = total/len(diff)

        print('Average accuracy: ' + str(avg) + '%\n')
Пример #2
0
def test():
    for name in filenames:
        print('Processing ' + name + '...')
        print('Actual || Expected || % Accuracy || isFlagged')

        diff = []

        # Process each image
        actual = script.process(name)
        with open('./expected/' + name + '.txt', 'r') as f:
            expected = f.read().strip().split('\n')

        # Calculate % accuracy
        for i in xrange(len(expected)):
            aline = actual[i][0]
            flagged = actual[i][3]
            eline = expected[i].strip()
            # ignore unnecessary lines eg. address
            if (eline.startswith('!')):
                continue

            acc = fuzz.ratio(aline, eline)
            diff.append(acc)
            print ' || '.join((aline, eline, str(acc), flagged))

        # average accuracy across all lines
        total = reduce(lambda x, y: x + y, diff)
        avg = total / len(diff)

        print('Average accuracy: ' + str(avg) + '%\n')
Пример #3
0
 def on_data(self, data):
     #print data
     #print type(data)
     d = json.loads(data)
     print d['text'].encode('utf-8')
     line = script.process(d, self.writers)
     return True
Пример #4
0
def startProcess(request):
    files = []
    keywords = []

    for key in request.FILES.keys():
        fs = FileSystemStorage()
        if fs.exists(request.FILES[key].name):
            fs.delete(request.FILES[key].name)
        fs.save(request.FILES[key].name, request.FILES[key])
        files.append(request.FILES[key].name)

    kws = request.POST['keywords'].split(',')
    for kw in kws:
        keywords.append(''.join(kw.split()))

    # print files, keywords
    process(keywords, files)
    return HttpResponse('sucess')