Exemplo n.º 1
0
def to_mbti(string, api):
    if string is None:
        return 'Error'
    elif 'http' in string:
        screen_name = get_screenname(string)
        final_str = ""
        count = 0
        for status in tweepy.Cursor(api.user_timeline,
                                    screen_name=screen_name,
                                    tweet_mode="extended").items():
            count += 1
            if count == 10:
                break
            print(final_str)
            final_str += status.full_text
    else:
        final_str = string

    mbti = classification.classify(final_str)

    return mbti
Exemplo n.º 2
0
def to_text(image):
    address_tag_coord, bar_code_coord = object_detection(image)
    if bar_code_coord:
        bar_code = crop(bar_code_coord, image)
        deskewd_bar = rotateImg(bar_code)
        bar = image_to_string(deskewd_bar)
        bar = purge_bar(bar)
    else:
        bar = None
        print('unable to locate bar code')
    if address_tag_coord:
        address_tag = crop(address_tag_coord, image)
        deskewed_address_tag = rotateImg(address_tag)
        cv2.imwrite('tmp/address_tag.jpg', deskewed_address_tag)
        printed = classify('tmp/address_tag.jpg')
        if printed:
            address = tesseract(deskewed_address_tag)
        else:
           address =  None
           print('unable to recognize hand written address tags')
    else:
        address = None
        print('unable to locate address tag')
    return address, bar