def test_correct(self):
     q = Quora()
     stats1 = q.scrape_question_stats(BeautifulSoup(open('tests/input_files/question_1')))
     stats2 = q.scrape_question_stats(BeautifulSoup(open('tests/input_files/question_2')))
     assert stats1 == EXPECTED_STATS_1
     assert stats2 == EXPECTED_STATS_2
     
 def test_correct(self):
     q = Quora()
     stats1 = q.scrape_question_stats(
         BeautifulSoup(open('tests/input_files/question_1')))
     stats2 = q.scrape_question_stats(
         BeautifulSoup(open('tests/input_files/question_2')))
     assert stats1 == EXPECTED_STATS_1
     assert stats2 == EXPECTED_STATS_2
Example #3
0
    def __init__(self, model='svm', features='bm25,', comment_features='bm25,', stop=True, vector='word2vec', path=FEATURES_PATH, alpha=0.1, sigma=0.9, gridsearch='random'):
        Quora.__init__(self, stop=stop, vector=vector)
        self.path = path
        self.features = features.split(',')
        self.comment_features = comment_features.split(',')
        self.gridsearch = gridsearch
        self.svm = Model()

        self.model = model
        self.bm25 = QuoraBM25(stop=stop) if 'bm25' in self.features+self.comment_features else None
        self.cosine = QuoraCosine(stop=stop) if 'cosine' in self.features+self.comment_features else None
        self.softcosine = QuoraSoftCosine(stop=stop, vector=vector) if 'softcosine' in self.features+self.comment_features else None
        self.translation = QuoraTranslations(alpha=alpha, sigma=sigma, stop=stop, vector=self.vector) if 'translation' in self.features+self.comment_features else None

        self.train()
class TestQuestionStatistics:
    q = Quora()
    stats1 = q.get_question_stats(
        'If-space-is-3-dimensional-can-time-also-be-3-dimensional')
    stats2 = q.get_question_stats(
        'I-need-a-summer-internship-but-I-dont-want-to-apply-because-theres-a-90-chance-Ill-get-rejected-What-should-I-do'
    )
    stats3 = q.get_question_stats(
        'What-are-the-best-intern-blog-posts-and-guides')
    stats4 = q.get_question_stats(
        'What-data-structures-and-algorithms-should-one-implement-in-order-to-prepare-for-technical-interviews'
    )
    test_stats = [stats1, stats2, stats3, stats4]

    # todo: add tests for nonexistant users and other edge cases

    @classmethod
    def setup_class(cls):
        print "Setup here"

    def test_exists(self):
        for stat in self.test_stats:
            assert stat['answer_count']
            assert stat['topics']

    def test_type(self):
        for stat in self.test_stats:
            assert isinstance(stat['answer_count'], (int, long))
Example #5
0
class TestActivity:
    q = Quora()
    activity1 = q.get_activity('Christopher-J-Su')
    activity2 = q.get_activity('Aaron-Ounn')
    test_activities = [activity1, activity2]

    @classmethod
    def setup_class(cls):
        print "Setup here"

    def test_activity_answers(self):
        for activity in self.test_activities:
            assert activity.answers
            assert activity.answers

    def test_activity_want_answers(self):
        for activity in self.test_activities:
            assert activity.want_answers
            assert activity.want_answers

    def test_activity_user_follows(self):
        for activity in self.test_activities:
            assert activity.user_follows
            assert activity.user_follows

    def test_activity_upvotes(self):
        for activity in self.test_activities:
            assert activity.user_follows
            assert activity.user_follows
Example #6
0
class TestActivity:
    q = Quora()
    stats1 = q.get_user_stats('Christopher-J-Su')
    stats2 = q.get_user_stats('Aaron-Ounn')
    stats3 = q.get_user_stats('Elynn-Lee')
    stats4 = q.get_user_stats('Jennifer-Apacible-1')
    test_stats = [stats1, stats2, stats3, stats4]

    # todo: add tests for nonexistant users and other edge cases

    @classmethod
    def setup_class(cls):
        print "Setup here"

    def test_exists(self):
        for stat in self.test_stats:
            assert stat['answers']
            assert stat['edits']
            assert stat['followers']
            assert stat['following']
            assert stat['questions']
            assert stat['name']
            assert stat['username']

    def test_type(self):
        for stat in self.test_stats:
            assert isinstance(stat['answers'], (int, long))
            assert isinstance(stat['edits'], (int, long))
            assert isinstance(stat['followers'], (int, long))
            assert isinstance(stat['following'], (int, long))
            assert isinstance(stat['posts'], (int, long))
            assert isinstance(stat['questions'], (int, long))
            assert isinstance(stat['name'], str)
            assert isinstance(stat['username'], str)
Example #7
0
def get_activity(name):
    activity = Quora.get_activity(name)
    data = {
        'Upvoted Answers': len(activity.upvotes),
        'Followed Topics': len(activity.user_follows),
        'Want Answers': len(activity.want_answers),
        'Review Requests': len(activity.review_requests)
    }
    return data
Example #8
0
def userstats_route (sunsign) :
	result = dict (Quora.getUserStats (username))
	return jsonify (answers=result['answers'],
			questions=result['questions'],
			shares=result['shares'],
                        spaces=result['spaces'],
                        posts=result['posts'],
                        blogs=result['blogs'],
                        followers=result['followers'],
                        following=result['following'])
Example #9
0
def user_review_requests_route(user):
    return jsonify({'items': Quora.get_activity(user).review_requests})
Example #10
0
def user_want_answers_route(user):
    return jsonify({'items': Quora.get_activity(user).want_answers})
Example #11
0
def user_activity_route(user):
    return jsonify(Quora.get_user_activity(user))
 def __init__(self, user):
     quora = Quora()
     self.activity = quora.get_activity(user)
     self.user = user
Example #13
0
def answer_stats_short_link_route(answer_short_link):
    return jsonify(Quora.get_one_answer(answer_short_link))
Example #14
0
from quora import Quora
from yahoo import Yahoo
from yandex import Yandex
from youtube import Youtube

scrapers = {
    'ask': Ask(),
    'baidu': Baidu(),
    'bing': Bing(),
    'dailymotion': Dailymotion(),
    'duckduckgo': Duckduckgo(),
    'exalead': Exalead(),
    'google': Google(),
    'mojeek': Mojeek(),
    'parsijoo': Parsijoo(),
    'quora': Quora(),
    'yahoo': Yahoo(),
    'yandex': Yandex(),
    'youtube': Youtube()
}


def small_test():
    assert isinstance(scrapers['google'].search('fossasia'), list)


def feedgen(query, engine, count=10):
    engine = engine.lower()
    # provide temporary backwards compatibility for old names
    old_names = {
        'ubaidu': 'baidu',
Example #15
0
def answerstats_route (question, username) :
	result = dict (Quora.getAnswerStats (question, username))
	return jsonify (views=result['views'],
			upvotes=result['upvotes'])
Example #16
0
#pip install quora
from quora import User, Quora

user = User('Christopher-J-Su')
activity = user.activity
print(activity)

question = Quora.get_question_stats('what-is-python')
print(question)

answer = Quora.get_one_answer('http://qr.ae/6hARL')
answer = Quora.get_one_answer('6hARL')
latest_answers = Quora.get_latest_answers('what-is-python')
 def test_quora(self):
     profile_data = Quora.scrap('John-Cate-2', 'firefox')
     self.assertIsInstance(profile_data, dict)
     self.assertEqual(len(profile_data), 11)
Example #18
0
def user_questions_route(user):
    return jsonify({'items': Quora.get_activity(user).questions})
Example #19
0
def userprofile_route (blogname) :
	result = dict (Quora.getUserProfile (username))
	return jsonify (credential=result['credential'],
			top_writer=result['top_writer'],
                        knows_about=result['knows_about'])
Example #20
0
def user_question_follows_route(user):
    return jsonify({'items': Quora.get_activity(user).question_follows})
Example #21
0
 def __init__(self, stop=True):
     Quora.__init__(self, stop=stop)
     self.train()
Example #22
0
def answer_stats_specific_user_alternate_route(question, user):
    return jsonify(Quora.get_one_answer(question, user=user))
Example #23
0
 def __init__(self, stop=True, vector='word2vec'):
     Quora.__init__(self, stop=stop, vector=vector)
     self.train()
Example #24
0
def answer_stats_specific_user_alternate_route(question, user):
    return jsonify(Quora.get_one_answer(question, user=user))
Example #25
0
def answer_route (sunsign) :
	result = dict (Quora.getAnswer (question, username))
	return jsonify (answer_text=result['answer'])
Example #26
0
 def __init__(self, alpha, sigma, stop=True, vector='word2vec'):
     Quora.__init__(self, stop=stop, vector=vector)
     self.alpha = alpha
     self.sigma = sigma
     self.train()
Example #27
0
 def __init__(self, user):
     quora = Quora()
     self.activity = quora.get_activity(user)
     self.user = user
Example #28
0
def user_stats_route(user):
    return jsonify(Quora.get_user_stats(user))
Example #29
0
def user_review_requests_route(user):
    return jsonify({'items': Quora.get_activity(user).review_requests})
Example #30
0
def user_user_follows_route(user):
    return jsonify({'items': Quora.get_activity(user).user_follows})
Example #31
0
from quora import Quora, Activity

quora = Quora()
stats = quora.get_user_stats('Christopher-J-Su')
# activity = quora.get_activity('Christopher-J-Su')
# print activity.answers
# print activity.question_follows
# print activity.user_follows
# print activity.upvotes
# print activity.questions
print stats
# print quora.get_activity_keys()
Example #32
0
def user_upvotes_route(user):
    return jsonify({'items': Quora.get_activity(user).upvotes})
Example #33
0
def user_activity_route(user):
    return jsonify(Quora.get_user_activity(user))
Example #34
0
def question_stats_route(question):
    return jsonify(Quora.get_question_stats(question))
Example #35
0
def blogstats_route (blogname) :
	result = dict (Quora.getBlogStats (blogname))
	return jsonify (description=result['description'],
			view=result['view'],
                        followers=result['followers'])
Example #36
0
    def test_correct(self):
        q = Quora()
        stats1 = q.scrape_one_answer(BeautifulSoup(open('tests/input_files/answer_1')))

        assert stats1 == EXPECTED_STATS_1
Example #37
0
from baidu import Baidu
from exalead import Exalead
from quora import Quora
from youtube import Youtube
from parsijoo import Parsijoo

scrapers = {
    'g': Google(),
    'b': Bing(),
    'y': Yahoo(),
    'd': Duckduckgo(),
    'a': Ask(),
    'yd': Yandex(),
    'u': Baidu(),
    'e': Exalead(),
    'q': Quora(),
    't': Youtube(),
    'p': Parsijoo()
}


def read_in():
    lines = sys.stdin.readlines()
    return json.loads(lines[0])


def small_test():
    assert isinstance(scrapers.google.results_search('fossasia'), list)


def feedgen(query, engine, count=10):
Example #38
0
def user_route(user):
    return jsonify(Quora.get_user_stats(user))
Example #39
0
def get_activity(name):
	activity = Quora.get_activity(name)
	data = {'Upvoted Answers':len(activity.upvotes), 'Followed Topics':len(activity.user_follows), 'Want Answers':len(activity.want_answers), 'Review Requests':len(activity.review_requests)}
	return data
Example #40
0
def user_answers_route(user):
    return jsonify({'items': Quora.get_activity(user).answers})
Example #41
0
def answer_stats_short_link_route(answer_short_link):
    return jsonify(Quora.get_one_answer(answer_short_link))
Example #42
0
def user_votes_route(user):
    return jsonify({'items': Quora.get_activity(user).upvotes})
Example #43
0
def question_stats_route(question):
    return jsonify(Quora.get_question_stats(question))