Exemplo n.º 1
0
def get_accept_rate(user_id=246246):

    #print 'StackOverflow user %d\'s experience:' % user_id

    so = Site(StackOverflow)
    user = so.user(user_id)

    #print 'Total badge count : %s'% user.badge_total
    global_sof_json['badges'] = user.badge_total
    global_sof_json['age'] = user.age
    global_sof_json['location'] = user.location
    global_sof_json['website'] = user.webiste_url

    if len(user.top_answer_tags.fetch()) > 0:
        global_sof_json['experienced'] = user.top_answer_tags.fetch()[0].tag_name

    #print 'Most experienced on %s.' % user.top_answer_tags.fetch()[0].tag_name
    #print 'Most curious about %s.' % user.top_question_tags.fetch()[0].tag_name

    total_questions = len(user.questions.fetch())
    unaccepted_questions = len(user.unaccepted_questions.fetch())
    accepted = total_questions - unaccepted_questions
    rate = accepted / float(total_questions) * 100
    global_sof_json['accept_rate'] = format(rate, '.2f')
from cassandra.cqlengine.models import Model
from cassandra.cluster import Cluster
import time
cluster = Cluster()
session = cluster.connect('stackoverflow')

f = open('finalUSERS.txt', 'r')
idlist = f.read().split(',')

combinedStats = []

i=1

with open('SOoutput.txt','a') as op:
	for id in idlist:
		user_stat = {}
		so = Site(StackOverflow)
		user = so.user(id)
		total_questions = user.questions.fetch()
		user_stat['userID'] = id
		questions_text = []
		for q in total_questions:
			questions_text.append(unicode(q).split("'")[1])
		user_stat['questions'] = questions_text
		combinedStats.append(user_stat)
		combined_questions = " ".join(questions_text)
		'''op.write('==='.encode('utf-8') + str(id).encode('utf-8') + ' '.encode('utf-8') + '<<< '.encode('utf-8') + combined_questions.encode('utf-8') + ' >>>'.encode('utf-8'))'''
		time.sleep(3)
		session.execute("INSERT INTO stackdata(id,questions) VALUES(%s,%s)", (int(id), combined_questions.encode('utf-8')))
		print 'finished inserting ' + str(i)
		i=i+1
Exemplo n.º 3
0
from __future__ import print_function
import sys
sys.path.append('.')
sys.path.append('..')
from stackexchange import Site, StackOverflow

user_id = 41981 if len(sys.argv) < 2 else int(sys.argv[1])
print('StackOverflow user %d\'s experience:' % user_id)

so = Site(StackOverflow)
user = so.user(user_id)

print('Most experienced on %s.' % user.top_answer_tags.fetch()[0].tag_name)
print('Most curious about %s.' % user.top_question_tags.fetch()[0].tag_name)

total_questions = len(user.questions.fetch())
unaccepted_questions = len(user.unaccepted_questions.fetch())
accepted = total_questions - unaccepted_questions
rate = accepted / float(total_questions) * 100
print('Accept rate is %.2f%%.' % rate)
Exemplo n.º 4
0
#!/usr/bin/env python

# a hack so you can run it 'python demo/stats.py'
import sys

sys.path.append(".")
sys.path.append("..")
from stackexchange import Site, StackOverflow

user_id = 41981 if len(sys.argv) < 2 else int(sys.argv[1])
print "StackOverflow user %d's experience:" % user_id

so = Site(StackOverflow)
user = so.user(user_id)

print "Most experienced on %s." % user.top_answer_tags.fetch()[0].tag_name
print "Most curious about %s." % user.top_question_tags.fetch()[0].tag_name

total_questions = len(user.questions)
unaccepted_questions = len(user.unaccepted_questions.fetch())
accepted = total_questions - unaccepted_questions
rate = accepted / float(total_questions) * 100
print "Accept rate is %.2f%%." % rate
from cassandra.cluster import Cluster
import time
cluster = Cluster()
session = cluster.connect('stackoverflow')

f = open('finalUSERS.txt', 'r')
idlist = f.read().split(',')

combinedStats = []

i = 1

with open('SOoutput.txt', 'a') as op:
    for id in idlist:
        user_stat = {}
        so = Site(StackOverflow)
        user = so.user(id)
        total_questions = user.questions.fetch()
        user_stat['userID'] = id
        questions_text = []
        for q in total_questions:
            questions_text.append(unicode(q).split("'")[1])
        user_stat['questions'] = questions_text
        combinedStats.append(user_stat)
        combined_questions = " ".join(questions_text)
        '''op.write('==='.encode('utf-8') + str(id).encode('utf-8') + ' '.encode('utf-8') + '<<< '.encode('utf-8') + combined_questions.encode('utf-8') + ' >>>'.encode('utf-8'))'''
        time.sleep(3)
        session.execute("INSERT INTO stackdata(id,questions) VALUES(%s,%s)",
                        (int(id), combined_questions.encode('utf-8')))
        print 'finished inserting ' + str(i)
        i = i + 1
Exemplo n.º 6
0
__FILENAME__ = experience
#!/usr/bin/env python

# a hack so you can run it 'python demo/stats.py'
import sys
sys.path.append('.')
sys.path.append('..')
from stackexchange import Site, StackOverflow

user_id = 41981 if len(sys.argv) < 2 else int(sys.argv[1])
print 'StackOverflow user %d\'s experience:' % user_id

so = Site(StackOverflow)
user = so.user(user_id)

print 'Most experienced on %s.' % user.top_answer_tags.fetch()[0].tag_name
print 'Most curious about %s.' % user.top_question_tags.fetch()[0].tag_name

total_questions = len(user.questions.fetch())
unaccepted_questions = len(user.unaccepted_questions.fetch())
accepted = total_questions - unaccepted_questions
rate = accepted / float(total_questions) * 100
print 'Accept rate is %.2f%%.' % rate

########NEW FILE########
__FILENAME__ = highest_voted
#!/usr/bin/env python

# a hack so you can run it 'python demo/stats.py'
import sys
sys.path.append('.')