Пример #1
0
    def get(self):
        if self.user:
            analyzer = StatusAnalyzer()
            user = self.user
            access_token = user.access_token
            results = urlfetch.fetch("https://graph.facebook.com/" +
                                     user.user_id + "/feed?access_token=" +
                                     access_token + "&limit=550",
                                     method=urlfetch.GET,
                                     deadline=10)
            wall = AttrDict(json.loads(results.content))
            classified_results = analyzer.classify(wall.data)
            stats, aggr = analyzer.aggregate(classified_results)
            friends = user.friends
            active_friends = analyzer.genRecentUsers(wall.data)
            inactive_friends = []
            for friend in friends:
                if not friend in active_friends:
                    inactive_friends.append(friend)

            self.render(u'analyze',
                        user=user,
                        stats=stats,
                        recent=active_friends,
                        inactive=inactive_friends)
        else:
            self.render(u'welcome')
Пример #2
0
    def get(self):
    	user = users.get_current_user()
	fetcher = StatusFetcher()
	analyzer = StatusAnalyzer()
    	global url,greeting,url_linktext

    	if users.get_current_user():
    		url = users.create_logout_url(self.request.uri)
    		greeting = 'Hi '+user.nickname()
    		url_linktext = 'Logout'
    	else:
    		url = users.create_login_url(self.request.uri)
    		greeting = 'Welcome Guest'
            	url_linktext = 'Login'
        
        trend_col = db.fetch_all_popular()
        id = []
	for x in trend_col:
   		id.append(x.fb_id)
	
        trend_id=random.choice(id)
	trend_wall = fetcher.FetchWall(trend_id)
	cloud = []
	for x in trend_wall.get("data"):
		y = ("%s" % x.get("message")).lower()
		y = re.sub(r'[^A-Za-z]'," ", y)
		cloud.append(y)
	trend_wall_info = fetcher.FetchInfo(trend_id)
	c_trend_wall = analyzer.classify(trend_wall.get("data"))
	stats,agres = analyzer.aggregate(c_trend_wall)
	rusers = analyzer.genRecentUsers(trend_wall.get("data"))
	template_values = {
    		'greeting': greeting,
    		'l_url':url,
    		'url_linktext':url_linktext,
		'pie':stats,
		'trend_img':trend_wall_info.picture,
		'fb_link':trend_wall_info.link,
		'trend_title':trend_wall_info.name,
		'fb_id':trend_wall_info.id,
		'cloud':analyzer.genTags(cloud),
		'tinfo':trend_wall_info,
		'users': rusers,
    	}

	path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
	self.response.out.write(template.render(path,template_values))	
Пример #3
0
	def get(self):
		id = self.request.get("id")
		c= BayesianClassifier()
		#access_token = self.request.cookies.get('at', '')

		analyzer = StatusAnalyzer()
		fetcher = StatusFetcher()
		info_dict = fetcher.FetchInfo(id)
		data = fetcher.FetchWall(id)
		classified_results = analyzer.classify(data.get("data"))			
			
		template_values = {
			 'id':info_dict.id,
			 'feed':classified_results,
			 'picture':info_dict.picture,
			 'likes':info_dict.likes,
			 'name':info_dict.name,
			 'category':info_dict.category,
    		}
		path = os.path.join(os.path.dirname(__file__), 'templates/analyze.html')
		self.response.out.write(template.render(path,template_values))	
Пример #4
0
    def get(self):
        id = self.request.get("id")
        c = BayesianClassifier()
        #access_token = self.request.cookies.get('at', '')

        analyzer = StatusAnalyzer()
        fetcher = StatusFetcher()
        info_dict = fetcher.FetchInfo(id)
        data = fetcher.FetchWall(id)
        classified_results = analyzer.classify(data.get("data"))

        template_values = {
            'id': info_dict.id,
            'feed': classified_results,
            'picture': info_dict.picture,
            'likes': info_dict.likes,
            'name': info_dict.name,
            'category': info_dict.category,
        }
        path = os.path.join(os.path.dirname(__file__),
                            'templates/analyze.html')
        self.response.out.write(template.render(path, template_values))
Пример #5
0
    def get(self):
        user = users.get_current_user()
        fetcher = StatusFetcher()
        analyzer = StatusAnalyzer()
        global url, greeting, url_linktext

        if users.get_current_user():
            url = users.create_logout_url(self.request.uri)
            greeting = 'Hi ' + user.nickname()
            url_linktext = 'Logout'
        else:
            url = users.create_login_url(self.request.uri)
            greeting = 'Welcome Guest'
            url_linktext = 'Login'

        trend_col = db.fetch_all_popular()
        id = []
        for x in trend_col:
            id.append(x.fb_id)

        trend_id = random.choice(id)
        trend_wall = fetcher.FetchWall(trend_id)
        cloud = []
        for x in trend_wall.get("data"):
            y = ("%s" % x.get("message")).lower()
            y = re.sub(r'[^A-Za-z]', " ", y)
            cloud.append(y)
        trend_wall_info = fetcher.FetchInfo(trend_id)
        c_trend_wall = analyzer.classify(trend_wall.get("data"))
        stats, agres = analyzer.aggregate(c_trend_wall)
        rusers = analyzer.genRecentUsers(trend_wall.get("data"))
        template_values = {
            'greeting': greeting,
            'l_url': url,
            'url_linktext': url_linktext,
            'pie': stats,
            'trend_img': trend_wall_info.picture,
            'fb_link': trend_wall_info.link,
            'trend_title': trend_wall_info.name,
            'fb_id': trend_wall_info.id,
            'cloud': analyzer.genTags(cloud),
            'tinfo': trend_wall_info,
            'users': rusers,
        }

        path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
        self.response.out.write(template.render(path, template_values))