Beispiel #1
0
	def menu_comment(user, q_n, language):
		"""Displays a menu to interact with the comment(s) of the given question/new.
		
		Args:
			language (dict): The language in which the information will be given.
            q_n (Question/New): The question/new's comment.
            user (User): The user that interacts with the comment(s).

		"""
		break_while = 0
		EXIT = 1
		while break_while != EXIT:
			print(language.get("separator"))
			print(language.get("coms"))
			print(q_n.show_comments(language))
			print(language.get("selectc"))
			option = input(language.get("inputtabs"))
			if option == "1":
				comment = Client.in_id(language, q_n)
				break_while1 = 0
				while break_while1 != EXIT:
					print(language.get("separator1"))
					print(language.get("comse"))
					print(comment.to_string(language))
					print(language.get("commento"))
					option1 = input(language.get("inputtabs"))
					if option1 == "1":
						Rating(user, comment, "like")
					elif option1 == "2":
						Rating(user, comment, "dislike")
					elif option1 == "3":
						print(language.get("l"))
						print(comment.watch_users_reactions(language, "like"))
					elif option1 == "4":
						print(language.get("dl"))
						print(comment.watch_users_reactions(language, "dislike"))
					elif option1 == "5":
						if user.repeated_fav(comment):
							print(language.get("fhs"))
						else:
							print(language.get("fs"))
					elif option1 == "6":
						Client.edit_comment(language, comment, user)
					elif option1 == "7":
						if comment.check_user(user):
							comment.delete_comment()
							Client.delete_favorite(comment)
							print(language.get("cod"))
							break_while1 = EXIT
						else:
							print(language.get("np"))
					elif option1 == "@":   #To go to the previous menu 
						break_while1 = EXIT
					else:
						print(language.get("i"))
						print(language.get("separator"))
			elif option == "@":
					break_while = EXIT
			else: 
				print(language.get("i"))
Beispiel #2
0
def movie_rate(user):
    movie_idX = input('Podaj ID filmu: ')
    rate = int(input("Podaj ocene (1-10): "))
    if (rate < 1 or rate > 10):
        print("Ocena ma byc od 1 do 10")
        rate = int(input("Podaj ocene (1-10): "))
    inBase = False
    x = Rating(None, movie_idX, rate, user)  #tworzenie obiektu klasy rating
    c.execute("SELECT movie_id, userName FROM rating")
    for userName, movie_id in c:
        if (user == userName and movie_idX == movie_id):
            print("Film juz oceniony")
            inBase = True
    if (inBase == False):
        c.execute(
            "INSERT INTO rating VALUES(:rate_id,:movie_id,:rate,:userName)", {
                'rate_id': x.rate_id,
                'movie_id': x.movie_id,
                'rate': float(x.rate),
                'userName': x.userName
            })
        conn.commit()
        print("Film Oceniony")
        sleep(1)
        os.system('cls')
        menu(user)
Beispiel #3
0
def new_rating():
    if request.method == 'GET':
        return render_template('index.html')
    elif request.method == 'POST':
        values = (None, request.form['movie'], request.form['rating'])
        rating = Rating(*values).create()
        logging.info('%s created new rating!', rating.movie)
        return redirect('/all')
Beispiel #4
0
 def ladder(self):
     s = sorted(self.scores, key=self.scores.get)
     rat = Rating()
     newR = rat.rate(s)
     for i in range(4):
         s[i].rating = round(newR[i])
         s[i].games += 1
         s[i].points += self.scores[s[i]]
         s[i].place[i] += 1
Beispiel #5
0
	def generate_f_data():
		"""Generates fictional data to load the program."""
		ch = Channel("Life","This channel is made to talk about life")
		ch2 = Channel("None", "none")
		u = User.users[random.choice(list(User.users.keys()))]
		u2 = User.users[random.choice(list(User.users.keys()))]
		while u == u2:
			u2 = User.users[random.choice(list(User.users.keys()))]
		a = Admin("Valentina", "Vvasquez", "*****@*****.**", "V123")
		q = Question(u, ch, "What is life?")
		c = Comment(u2, q, "That is; in fact, a hard question, what would it be?")
		r = Rating(u2, q, "like")
		r1 = Rating(a, c, "dislike")
		q2 = Question(u2, ch, "What is love?")
		c2 = Comment(u, q2, "The affection you feel for someone; or even, something.")
		r2 = Rating(a, q2, "dislike")
		q3 = Question(a, ch, "What is Death?")
		n = New(a, "The hollow has come!", "That witch has taken my daughthers body.", "Niklaus.", "Drama")
Beispiel #6
0
 def __init__(self,
              title='',
              director='',
              actors=[],
              rating_information={}):
     self.title = title
     self.director = director
     self.actors = actors
     self.rating = Rating(rating_information)
    def set_rating(self, user_or_ip, rating):
        '''Record a user's rating of this package.

        The caller function is responsible for doing the commit.

        If a rating is outside the range MAX_RATING - MIN_RATING then a
        RatingValueException is raised.

        @param user_or_ip - user object or an IP address string
        '''
        user = None
        from user import User
        from rating import Rating, MAX_RATING, MIN_RATING
        if isinstance(user_or_ip, User):
            user = user_or_ip
            rating_query = meta.Session.query(Rating)\
                               .filter_by(package=self, user=user)
        else:
            ip = user_or_ip
            rating_query = meta.Session.query(Rating)\
                               .filter_by(package=self, user_ip_address=ip)

        try:
            rating = float(rating)
        except TypeError:
            raise RatingValueException
        except ValueError:
            raise RatingValueException
        if rating > MAX_RATING or rating < MIN_RATING:
            raise RatingValueException

        if rating_query.count():
            rating_obj = rating_query.first()
            rating_obj.rating = rating
        elif user:
            rating = Rating(package=self,
                            user=user,
                            rating=rating)
            meta.Session.add(rating)
        else:
            rating = Rating(package=self,
                            user_ip_address=ip,
                            rating=rating)
            meta.Session.add(rating)
def get_ratings(episode, next_rating_number):
    global current_scores
    ratings = {}
    for person, score in current_scores.items():
        new_rating = Rating(episode.number, episode.date, episode.epoch,
                            person, episode.restaurant, score)
        ratings["_" + str(next_rating_number)] = new_rating
        next_rating_number += 1

    return ratings
 def __init__(
     self,
     name,
     suburb,
     service_type,
     description,
 ):
     self._name = name
     self._suburb = suburb
     self._service_type = service_type
     self._description = description
     self._doctors = []
     self._rating = Rating()
Beispiel #10
0
 def __init__(self, title="", votes="", date="", description="", genres="", released=False):
     self.title = title
     self.title_eng = ""
     self.votes = votes
     self.date = date
     self.description = description
     self.genres = genres
     self.year = 0
     self.rating = Rating()
     self.url = None
     self.poster_imdb = None
     self.poster_fweb = None
     self.poster_imdb_full = None
     self.released = released
     self.runtime = 0
Beispiel #11
0
def testRating(reader, similarity):
    dict = {}
    ratingList = []
    for line in reader:
        ratingValue = int(line['Rating'])
        if ratingValue in dict:
            dict[ratingValue] += 1
        else:
            dict[ratingValue] = 1

    for ratingValue, count in dict.items():
        rating = Rating()
        rating.ratingValue = ratingValue
        rating.count = count
        ratingList.append(rating)
    ratingCalculator = RatingCalculator()
    print ratingCalculator.calculateRating(ratingList, similarity)
Beispiel #12
0
 def identify_teams_and_players(self):
     f = open("Game_Lineup.txt", 'r')
     i = 0
     for line in f:
         if i == 0:
             i += 1
         else:
             tokens = line.split()
             game_id = tokens[0].strip('"')
             period = int(tokens[1])
             player_id = tokens[2].strip('"')
             team_id = tokens[3].strip('"')
             status = tokens[4].strip('"')
             if game_id == self.game_id:
                 if team_id not in self.team_ids:
                     self.add_team(team_id)
                 if period == 0:
                     self.ratings[player_id] = Rating(
                         game_id, team_id, player_id)
     f.close()
Beispiel #13
0
from cityCode_process import CityProcess
from lda import LDAProcess
from rating import Rating
import numpy as np
import matplotlib.pyplot as plt


city = CityProcess()
rate = Rating()
cities = city.loadData()
lda = LDAProcess()
lda.loadData()
n_groups = 5
res1 = rate.rate("topic/topic0.txt")
res2 = rate.rate("topic/topic1.txt")
res3 = rate.rate("topic/topic2.txt")
res4 = rate.rate("topic/topic3.txt")
res5 = rate.rate("topic/topic4.txt")
res6 = rate.rate("topic/topic5.txt")
res7 = rate.rate("topic/topic6.txt")
res8 = rate.rate("topic/topic7.txt")
res9 = rate.rate("topic/topic8.txt")
res10 = rate.rate("topic/topic9.txt")

fig, ax = plt.subplots()
index = np.arange(n_groups)
bar_width = 0.15
opacity = 0.4

res11 = []
Beispiel #14
0
	def menu_new(user, language):
		"""Displays a menu to interact with the new(s).

		Args:
			language (dict): The language in which the information will be given.
            user (User): The user that interacts with the new(s).

		"""
		break_while = 0
		EXIT = 1
		while break_while != EXIT:
			print(language.get("separator1"))
			print(language.get("selectn"))
			option = input(language.get("inputtabs"))
			if option == "1":
				if isinstance(user, Admin):
					new = Client.upload_a_new(language, user)
				else:
					print(language.get("np"))
				break_while = EXIT
			elif option == "2":
				if len(New.news):
					Client.show_news(language)
					new = Client.in_id(language)
					new.increase_views()
					break_while1 = 0
					while break_while1 != EXIT:
						print(language.get("separator1"))
						print(language.get("ns"))
						print(new.to_string(language))
						print(language.get("newo"))
						option1 = input(language.get("inputtabs"))
						if option1 == "1":
							print(language.get("separator"))
							comment = Client.comment(language, user, new)
							print(comment.to_string(language))
						elif option1 == "2":
							if len(new.show_comments(language)): 
								Client.menu_comment(user, new, language)
							else:
								print(language.get("ncn"))
						elif option1 == "3":
							Rating(user, new, "like")
						elif option1 == "4":
							Rating(user, new, "dislike")
						elif option1 == "5":
							print(language.get("l"))
							print(new.watch_users_reactions(language, "like"))
						elif option1 == "6":
							print(language.get("dl"))
							print(new.watch_users_reactions(language, "dislike"))
						elif option1 == "7":
							if user.repeated_fav(new):
								print(language.get("fhs"))
							else:
								print(language.get("fs"))
						elif option1 == "8":
							Client.edit_new(language, new, user)
						elif option1 == "9":
							if new.check_user(user):
								new.delete_new()
								print(language.get("nd"))
							else:
								print(language.get("np"))
							break_while1 = EXIT
						elif option1 == "@":
							break_while1 = EXIT
						else:
							print(language.get("i"))
				else:
					print(language.get("nnews"))
			elif option == "3":
				print(language.get("separator"))
				print(language.get("topn"))
				print(Client.top_news(language))
				break_while1 = 0
				EXIT = 1
				while break_while1 != EXIT:
					print(language.get("gbp"))
					option1 = input(language.get("inputtabs"))
					if option1 == "@":
						break_while1 = EXIT
					else:
						print(language.get("i"))
			elif option == "@":
				break_while = EXIT
			else:
				print(language.get("i"))
Beispiel #15
0
	def menu_question(user, channel, language):
		"""Displays a menu to interact with the question(s) of the given channel.

		Args:
			language (dict): The language in which the information will be given.
            channel (Channel): The question's channel.
            user (User): The user that interacts with the question(s).

		"""
		break_while = 0
		EXIT = 1
		while break_while != EXIT:
			print(language.get("separator"))
			print (language.get("qs"))
			print(channel.to_string1(language))
			print(language.get("selectq"))
			option = input(language.get("inputtabs"))
			if option == "1":
				question = Client.in_id(language, channel)
				question.increase_views()
				break_while1 = 0
				while break_while1 != EXIT:
					print (language.get("separator1"))
					print (language.get("ps"))
					print(question.to_string(language))
					print(language.get("questiono"))
					option1 = input(language.get("inputtabs"))
					if option1 == "1":
						comment = Client.comment(language, user, question)
						print(comment.to_string(language))
					elif option1 == "2":
						if len(question.show_comments(language)): 
							Client.menu_comment(user, question, language)
						else:
							print(language.get("ncq"))
					elif option1 == "3":
							Rating(user, question, "like")
					elif option1 == "4":
							Rating(user, question, "dislike")
					elif option1 == "5":
							print(language.get("l"))
							print(question.watch_users_reactions(language, "like"))
					elif option1 == "6":
							print(language.get("dl"))
							print(question.watch_users_reactions(language, "dislike"))
					elif option1 == "7":
						if user.repeated_fav(question):
							print(language.get("fhs"))
						else:
							print(language.get("fs"))
					elif option1 == "8":
						Client.edit_question(language, question, user)
					elif option1 == "9":
						if question.check_user(user):
							question.delete_question()
							Client.delete_favorite(question)
							print(language.get("qd"))
						else:
							print(language.get("np"))
						break_while1 = EXIT
					elif option1 == "@":
						break_while1 = EXIT
					else:
						print(language.get("i"))
			elif option == "@":   #To go to the previous menu 
				break_while = EXIT
			else:
				print(language.get("i"))
Beispiel #16
0
 def __init__(self, username, password, name, profile):
     HASUser.__init__(self, username, password, 'health_provider', name)
     self._profile = profile
     self._healthCentre = []
     self._rating = Rating()
Beispiel #17
0
 def __init__(self, Moves, playerIsWhite, maxDepth):
     self.Moves = Moves
     self.Rating = Rating(Moves)
     self.playerIsWhite = playerIsWhite
     self.maxDepth = maxDepth
Beispiel #18
0
 def __init__(self):
     self.rating = Rating()
     self.history = []
def readRatings():
    with open(ratingsFileName, 'r') as ratingsFile:
            data = ratingsFile.readlines()
            for line in data:
                userId, movieId, rating, timestamp = line.split(delimiter)
                ratings.append(Rating(userId, movieId, rating, timestamp))