Example #1
0
def profile(profileId):
    authCookie = request.cookies.get('linkedin_oauth_%s' % cfg.get('auth', 'consumer_key'))
    authString = urllib.unquote(authCookie)

    # profile
    LinkedIn = LinkedInApi.LinkedInApi(session['linkedin_oauth_token'], session['linkedin_oauth_secret'])
    profile = parser.parse(LinkedIn.profile(profileId))
    print
    #print profile
    print
    positions = profile['positions']['values']
    raw = nlp.ascii(parser.raw(profile))
    tokens = nlp.tokenize(raw)
    tokens = nlp.normalize(tokens)
    token_str = ' '.join(tokens)
    freq = ' '.join(nlp.freq_dist(tokens, 3))
    # connections
    parser_parse = parser.parse(LinkedIn.connections(profileId))
    # we can't (yet) get to our connections connections
    if 'message' in parser_parse.keys():
        print parser_parse
        connections = []
    else:
        connections = parser_parse['values']
    # context
    context = {}
    context['id'] = authString
    context['profile'] = profile
    context['positions'] = positions
    context['tokens'] = token_str
    context['connections'] = connections
    context['frequent'] = freq
    return render_template('profile.html', **context)
def doIt():
    json_prof = api.profile()
    print json_prof

    profile = parser.parse(json_prof)
    #print "Name: " + profile['firstName'] + ' ' + profile['lastName']
    raw = parser.raw(profile)
    raw = nlp.ascii(raw)

    tokens = nlp.tokenize(raw)
    tokens = nlp.normalize(tokens)
    print "Tokens:"
    print ' '.join(tokens)

    freq = nlp.freq_dist(tokens, 3)
    print "Frequent:"
    print ' '.join(freq)

    vocab = nlp.vocabulary(tokens)
    print "Vocabulary: "
    print vocab

    text = nltk.Text(tokens)
    print "Text: " + str(type(text))