<commit_before>! Copyright (C) 2011 <NAME>
! See http://factorcode.org/license.txt for BSD license

USING: accessors assocs classes.tuple formatting http.client
images.http json.reader kernel sequences strings ;

IN: gravatar

TUPLE: info aboutMe accounts currentLocation displayName emails
hash id ims name phoneNumbers photos preferredUsername
profileBackground profileUrl requestHash thumbnailUrl urls ;

: gravatar-info ( gravatar-id -- info )
    "http://gravatar.com/%s.json" sprintf http-get nip
    >string json> "entry" of first info from-slots ;

: gravatar. ( gravatar-id -- )
    gravatar-info thumbnailUrl>> http-image. ;<commit_msg>gravatar: implement the "email hash" to calculate the gravatar id.<commit_after>! Copyright (C) 2011 <NAME>
! See http://factorcode.org/license.txt for BSD license

USING: accessors ascii assocs checksums checksums.md5
classes.tuple formatting http.client images.http json.reader
kernel math.parser sequences strings ;

IN: gravatar

TUPLE: info aboutMe accounts currentLocation displayName emails
hash id ims name phoneNumbers photos preferredUsername
profileBackground profileUrl requestHash thumbnailUrl urls ;

: gravatar-id ( email -- gravatar-id )
    [ blank? ] trim >lower md5 checksum-bytes bytes>hex-string ;

: gravatar-info ( gravatar-id -- info )
    "http://gravatar.com/%s.json" sprintf http-get nip
    >string json> "entry" of first info from-slots ;

: gravatar. ( gravatar-id -- )
    gravatar-info thumbnailUrl>> http-image. ;
{'fraction_non_alphanumeric': 0.09450402144772117, 'fraction_numerical': 0.006702412868632708, 'mean_word_length': 4.370503597122302, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5424763', 'n_tokens_mistral': 451, 'n_tokens_neox': 435, 'n_words': 144}