def RunTest(self):
     TestR=Restaurant(2)
     guest=Guest('Mary',3)
     assert TestR.seat(guest)==True,'Incorrect seating function'
     guest1=Guest('John',2)
     assert TestR.seat(guest1)==True,'Incorrect seating function'
     guest2=Guest('Alice',1)
     assert TestR.seat(guest2)==False,'Incorrect seating function'
     print("Test of seating function in restaurant is successful\n")
Example #2
0
    def test_changeBoundary(self):

        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文章を適当に作成
        u1 = ["生きてる", "こと", "が", "つらい", "なら"]

        # for i in range(15):
        #     print(rest.changeBoundary(u1, i))

        flag = True
        result = rest.changeBoundary(u1, 0)
        expected = ["生", "きてる", "こと", "が", "つらい", "なら"]
        flag = flag and (result == expected)
        result = rest.changeBoundary(u1, 3)
        expected = ["生きてること", "が", "つらい", "なら"]
        flag = flag and (result == expected)
        result = rest.changeBoundary(u1, 5)
        expected = ["生きてる", "ことが", "つらい", "なら"]
        flag = flag and (result == expected)
        result = rest.changeBoundary(u1, 6)
        expected = ["生きてる", "こと", "がつらい", "なら"]
        flag = flag and (result == expected)
        result = rest.changeBoundary(u1, 11)
        expected = ["生きてる", "こと", "が", "つらい", "なら"]
        flag = flag and (result == expected)
        result = rest.changeBoundary(u1, 100)
        expected = ["生きてる", "こと", "が", "つらい", "なら"]
        flag = flag and (result == expected)

        self.assertTrue(flag)
Example #3
0
    def test_sampling(self):
        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文脈を適当に挿入
        u1 = ["生きてる", "こと", "が", "つらい", "なら"]
        u2 = ["生きてる", "こと", "が", "つらい", "なら"]
        u3 = ["生きてる", "こと", "が", "つらい", "なら"]
        u4 = ["生きてる", "こと", "が", "つらい", "なら"]
        u5 = ["いっそ", "小さく", "死ね", "ば", "いい"]
        u6 = ["喚き", "散らして", "泣け", "ば", "いい"]

        rest.addCustomerfromSentence(u1)
        rest.addCustomerfromSentence(u2)
        rest.addCustomerfromSentence(u3)
        rest.addCustomerfromSentence(u4)
        rest.addCustomerfromSentence(u5)

        # 確率計算
        print(rest.calcProbability(u1))
        print(rest.calcProbability(u5))
        print(rest.calcProbability(u6))

        # サンプリング
        rest.sampling(u1)

        self.assertTrue(True)
Example #4
0
def load_mongo(table_list, place_id):
    #global okt
    seq_list = []
    rest_list = []
    conn = pymongo.MongoClient('118.220.3.71', 27017)
    db = conn['crawling']
    for table in table_list:
        print(table)
        reviews = db[table].find({'place_id': place_id})
        try:
            for r in reviews:
                rest = Restaurant.Restaurant(r['_id'], r['name'], r['date'],
                                             r['r_addr'], r['r_lat'],
                                             r['r_lng'], r['r_name'],
                                             strip_e(r['comment']))
                rest_list.append(rest)
                pos = Okt().pos(strip_e(r['comment']).replace("#",
                                                              " ").replace(
                                                                  "\n", " "),
                                norm=True,
                                stem=True)
                seq_list.append(pos)
        except:
            continue

    return seq_list, rest_list
Example #5
0
    def _test_executeParsing(self):
        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文脈を適当に挿入
        u = []
        u.append(["生きてることがつらいなら"])
        u.append(["いっそ小さく死ねばいい"])
        u.append(["恋人と親は悲しむが"])
        u.append(["三日とたてば元通り"])
        u.append(["気が付きゃみんな年取って"])
        u.append(["おんなじところに行くのだから"])
        u.append(["生きてることがつらいなら"])
        u.append(["喚き散らしてなけばいい"])
        u.append(["そのうち夜は明けちゃって"])
        u.append(["疲れて眠りにつくだろう"])
        u.append(["夜に泣くのは赤ん坊"])
        u.append(["だけって決まりはないんだし"])
        u.append(["生きてることがつらいなら"])
        u.append(["悲しみをとくと見るがいい"])
        u.append(["悲しみはいつか一片の"])
        u.append(["お花みたいに咲くという"])
        u.append(["そっと伸ばした両の手で"])
        u.append(["摘み取るんじゃなく守るといい"])
        u.append(["何にもないところから何にもないところへと"])
        u.append(["なんにもなかったかのように"])
        u.append(["めぐる命だから"])
        u.append(["生きてることがつらいなら"])
        u.append(["嫌になるまで生きるがいい"])
        u.append(["歴史は小さなブランコで"])
        u.append(["宇宙は小さな水飲み場"])
        u.append(["生きてることがつらいなら"])
        u.append(["くたばる喜びとっておけ"])

        rest.executeParsing(u, 100000)
Example #6
0
def sms():
    reservInfo = " "
    # Start our response

    resp = MessagingResponse()

    #user input
    message_body = request.form['Body']

    count = 0
    name = " "
    time = " "

    file = open("Reservations.txt", "a")

    #check for # of spaces, if two words assume data correct
    for i in range(len(message_body) - 1):
        if message_body[i] == " ":
            count = count + 1

#Parse the user response to a name and time
    if count == 1:
        for i in range(len(message_body) - 1):
            if message_body[i] == " ":  #first space
                name = message_body[0:i]
                time = message_body[i + 1:len(message_body)]
                print name
                print time
        #if time is not a number, request user to enter a valid number
        if is_number(time) == False:
            resp.message('Please input time as a valid number.')
            return str(resp)

    #If reservation time is not booked, create a reservation
        res = Reservation.Reservation(name, time)
        rest = Restaurant.Restaurant()
        if rest.add_reservation(res.get_time()) == True:
            resp.message('Your reservation is confirmed. Thank you!')
            file.write(res.get_name())
            file.write(" ")
            file.write(str(res.get_time()))

            file.close()
            return str(resp)
    #Request user select another time
        else:
            resp.message('This time is booked. Select another time.')
            return str(resp)
            #run alternate_reservation method to give user options
            # temp_times = resp.message(rest.alternate_reservation(res.get_time()))
            # for t in temp_times:

            # resp.message('This time is taken. Please pick another')
            # return str(resp)

    else:
        #tell them to send the correct information
        print "checkpoint 1"
        resp.message('Welcome to Entree! Send us your last name and the time.')
        return str(resp)
Example #7
0
def new_game(main_scr):
    """Function that create a new game"""
    curses.curs_set(2)
    # Show the cursor
    main_scr.clear()
    # Clear the main_screen
    curses.echo()
    # Display what the user is writting

    main_scr.addstr(3, 5, "Quel est votre prénom ? ")
    surname = main_scr.getstr().decode("utf-8")
    main_scr.addstr(4, 5, "Quel est votre nom ? ")
    name = main_scr.getstr().decode("utf-8")

    while (existing_game(name)):  # Check if the game already exists
        main_scr.clear()
        main_scr.addstr(3, 5, "Cette partie existe déjà...")
        main_scr.addstr(4, 5, "Quel est votre prénom ? ")
        surname = main_scr.getstr().decode("utf-8")
        main_scr.addstr(5, 5, "Quel est votre nom ? ")
        name = main_scr.getstr().decode("utf-8")

    curses.noecho()
    # Hide typed character
    curses.curs_set(0)
    # Hide the cursor

    restaurant_ = Restaurant.Restaurant(name, surname)

    return (restaurant_)
 def setUpClass(self):
     self.rest = Restaurant.Restaurant(None, [])
     u1 = ["昨夜", "眠れずに", "失望", "と", "戦った"]
     u2 = ["昨夜", "一晩中", "欲望", "と", "戦った"]
     u3 = ["だから", "一晩中", "絶望", "と", "戦った"]
     self.rest.addCustomerfromSentence(u1)
     self.rest.addCustomerfromSentence(u2)
     self.rest.addCustomerfromSentence(u3)
def getRestaurantData():
    global noOfRestaurants
    db = getConnection()
    collection = db.businesses
    for restaurant in collection.find().limit(500):
        restaurantObj = r.Restaurant(restaurant)
        restaurantList.append(restaurantObj)
        restIdList.append(restaurantObj.restaurantId)
    noOfRestaurants = len(restaurantList)
Example #10
0
def newRestaurant():
    if request.method == 'POST':
        newRestaurant = Restaurant(name=request.form['name'])
        session.add(newRestaurant)
        flash('New Restaurant %s Successfully Created' % newRestaurant.name)
        session.commit()
        return redirect(url_for('showRestaurants'))
    else:
        return render_template('newRestaurant.html')
Example #11
0
    def test_isCollectTerminalNode(self):

        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文脈を適当に挿入
        u = ["今日", "も", "また", "人が", "死んだよ"]
        rest.addCustomerfromSentence(u)
        result = rest.getChildofForrowedU(u[:-1]).getU()
        expected = u[:-1]
        self.assertEqual(expected, result)
Example #12
0
    def importRestaurant(self):

        file = Restaurant.getNextFile()
        if not file:
            tkinter.messagebox.showinfo(message="There are no new Restaurant files")
            return

        orders = Restaurant.getOrders(file, self.orderColumns)
        items = Restaurant.getItems(file, self.itemColumns)
        packages = Restaurant.getPackages(file, self.packageColumns)
        Restaurant.outputErrors()
        Restaurant.archiveFile(file)
        self.importOrders(os.path.basename(file), orders, items, packages)
Example #13
0
    def importRestaurant(self):

        file = Restaurant.getNextFile()
        if not file:
            tkinter.messagebox.showinfo(
                message='There are no new Restaurant files')
            return

        orders = Restaurant.getOrders(file, self.orderColumns)
        items = Restaurant.getItems(file, self.itemColumns)
        packages = Restaurant.getPackages(file, self.packageColumns)
        Restaurant.outputErrors()
        Restaurant.archiveFile(file)
        self.importOrders(os.path.basename(file), orders, items, packages)
Example #14
0
    def _test_calcProbabilityofForrowedU_hard(self):

        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文脈を適当に挿入

        u1 = ["生きてる", "こと", "が", "つらい", "なら"]
        u2 = ["いっそ", "小さく", "死ね", "ば", "いい"]
        u3 = ["生きてる", "こと", "が", "つらい", "なら"]
        u4 = ["喚き", "散らして", "泣け", "ば", "いい"]
        u5 = ["生きてる", "こと", "が", "つらい", "なら"]
        u6 = ["悲しみ", "を", "とくと", "見る", "が", "いい"]
        u7 = ["生きてる", "こと", "が", "つらい", "ならば"]
        u8 = ["くたばる", "喜び", "とっておけ"]

        rest.addCustomerfromSentence(u1)
        rest.addCustomerfromSentence(u2)
        rest.addCustomerfromSentence(u3)
        rest.addCustomerfromSentence(u4)
        rest.addCustomerfromSentence(u5)
        rest.addCustomerfromSentence(u6)
        rest.addCustomerfromSentence(u7)
        rest.addCustomerfromSentence(u8)

        # rest.toPrint()

        u = ["生きてる", "こと", "が", "つらい"]
        w1 = "なら"
        w2 = "ならば"
        w3 = "いい"
        w4 = "おっぺけぺ~"
        w5 = "だいだげき!"
        p1 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w1))
        p2 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w2))
        p3 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w3))
        p4 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w4))
        p5 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w5))

        t1 = (p1 == 0.29297422954417)
        t2 = (p2 == 0.15011708668702714)
        t3 = (p3 == 0.04050244972864021)
        t4 = (p4 == 0.015967311912252386)
        t5 = (p5 == 0.015967311912252386)
        """
        print(t1)
        print(t2)
        print(t3)
        print(t4)
        print(t5)
        """

        self.assertTrue(t1 and t2 and t3 and t4 and t5)
Example #15
0
    def test_isCollectCustomers(self):

        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文脈を適当に挿入

        u1 = ["昨夜", "眠れずに", "失望", "と", "戦った"]
        u2 = ["昨夜", "一晩中", "欲望", "と", "戦った"]
        u3 = ["だから", "一晩中", "絶望", "と", "戦った"]
        rest.addCustomerfromSentence(u1)
        rest.addCustomerfromSentence(u2)
        rest.addCustomerfromSentence(u3)
        """
        uA = []
        uB = ["今日"]
        uC = ["今日", "も"]
        uD = ["今日", "も", "また"]
        uE = ["今日", "も", "また", "俺は"]
        """
        uA = []
        uB = ["と"]
        uC = ["欲望", "と"]
        uD = ["一晩中", "欲望", "と"]
        uE = ["昨夜", "一晩中", "欲望", "と"]

        chiA = rest.getChildofForrowedU(uA)
        chiB = rest.getChildofForrowedU(uB)
        chiC = rest.getChildofForrowedU(uC)
        chiD = rest.getChildofForrowedU(uD)
        chiE = rest.getChildofForrowedU(uE)

        # rest.toPrint()

        result = []
        result.append(len(chiA.customers))
        result.append(len(chiB.customers))
        result.append(len(chiC.customers))
        result.append(len(chiD.customers))
        result.append(len(chiE.customers))

        # (                )  の客は 「昨夜」13個
        #   (全13単語中,同じ文脈からしか生じない「戦った」を1個と数える)
        # (と              )  の客は 「戦った」3個
        # (欲望と          )  の客は 「戦った」1個
        # (一晩中欲望と    )  の客は 「戦った」1個
        # (昨夜一晩中欲望と)  の客は 「戦った」1個
        expected = [13, 3, 1, 1, 1]
        self.assertEqual(expected, result)
Example #16
0
 def createSets(self):
     '''
     Divides up the restaurants into multiple sets
     '''
     restDict = self.extractor.obtainBussInfo(
     )  #get the dictionary of businesses
     for rest in restDict:
         filename = rest[
             -1]  #use the ascii value of the last character in the businessID for the filename
         #map each possible filename to a restaurant set
         if filename not in self.restaurantSets:
             self.restaurantSets.update(
                 {filename: RestaurantSet.RestaurantSet(filename)})
         self.restaurantSets[filename].appendRestaurant(
             Restaurant.Restaurant(restDict[rest]),
             rest)  #add the restaurant to the appropriate set
Example #17
0
    def test_calcProbabilityofForrowedU(self):

        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文脈を適当に挿入

        u1 = ["生きてる", "こと", "が", "つらい", "なら"]
        u2 = ["いっそ", "小さく", "死ね", "ば", "いい"]
        u3 = ["生きてる", "こと", "が", "つらい", "なら"]
        u4 = ["喚き", "散らして", "泣け", "ば", "いい"]
        u5 = ["生きてる", "こと", "が", "つらい", "なら"]
        u6 = ["悲しみ", "を", "とくと", "見る", "が", "いい"]
        u7 = ["生きてる", "こと", "が", "つらい", "ならば"]
        u8 = ["くたばる", "喜び", "とっておけ"]

        rest.addCustomerfromSentence(u1)
        rest.addCustomerfromSentence(u2)
        rest.addCustomerfromSentence(u3)
        rest.addCustomerfromSentence(u4)
        rest.addCustomerfromSentence(u5)
        rest.addCustomerfromSentence(u6)
        rest.addCustomerfromSentence(u7)
        rest.addCustomerfromSentence(u8)

        # rest.toPrint()

        u = ["生きてる", "こと", "が", "つらい"]
        w1 = "なら"
        w2 = "ならば"
        w3 = "いい"
        w4 = "おっぺけぺ~"
        w5 = "だいだげき!"
        p1 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w1))
        p2 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w2))
        p3 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w3))
        p4 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w4))
        p5 = (rest.getChildofForrowedU(u).calcProbabilityofForrowedU(w5))
        """
        print(rest.getChildofForrowedU(u).getU())
        print(p1)
        print(p2)
        print(p3)
        print(p4)
        print(p5)
        """

        self.assertTrue((p1 > p2) and (p2 > p3) and (p3 > p4) and (p4 == p5))
Example #18
0
def getent():
    b = int(ID.get())
    c = password.get()
    if b == 1:
        if c == "123manage":
            staff()
        else:
            root = Tk()
            root.withdraw()
            messagebox.showerror("Error", "Wrong Password or Id")
    elif b == 2:
        if c == "123":
            Restaurant()
        else:
            root = Tk()
            root.withdraw()
            messagebox.showerror("Error", "Wrong Password or Id")

    else:
        root = Tk()
        root.withdraw()
        messagebox.showerror("Error", "Wrong Password or Id")
Example #19
0
def load_spark(table_list, place_id):
    seq_list = []
    rest_list = []
    for table in table_list:
        spark_session = SparkSession.builder.appName(place_id).master("local[*]") \
            .config("spark.mongodb.output.uri", "mongodb://118.220.3.71/crawling")\
            .config("spark.mongodb.output.collection", table)\
            .config("spark.mongodb.input.uri", "mongodb://118.220.3.71/crawling")\
            .config("spark.mongodb.input.collection", table) \
            .config("spark.local.dir", "C:/tmp/hive/") \
            .config('spark.jars.packages', 'org.mongodb.spark:mongo-spark-connector_2.11:2.3.1') \
            .getOrCreate()
        df = spark_session.read.format(
            "com.mongodb.spark.sql.DefaultSource").load()
        df.printSchema()
        try:
            df.createOrReplaceTempView(table)
            result = spark_session.sql("SELECT * FROM " + table +
                                       " Where place_id = '" + place_id +
                                       "'").rdd
            for r in result.collect():
                rest = Restaurant.Restaurant(r['_id'], r['name'], r['date'],
                                             r['r_addr'], r['r_lat'],
                                             r['r_lng'], r['r_name'],
                                             strip_e(r['comment']))
                rest_list.append(rest)
                pos = Okt().pos(strip_e(r['comment']).replace("#",
                                                              " ").replace(
                                                                  "\n", " "),
                                norm=True,
                                stem=True)
                seq_list.append(pos)
        except:
            pass

        df.drop()
        spark_session.stop()

    return seq_list, rest_list
Example #20
0
    def _test_isCollectTree(self):

        # 根店を生成
        rest = Restaurant.Restaurant(None, [])
        # 文脈を適当に挿入

        u1 = ["今日", "も", "また", "人が", "死んだよ"]
        u2 = ["今日", "も", "また", "俺は", "元気"]
        u3 = ["今日", "も", "また", "俺は", "残業"]
        rest.getChildofForrowedU(u1)
        rest.getChildofForrowedU(u2)
        rest.getChildofForrowedU(u3)

        uA = ["今日", "も"]
        uB = ["今日", "も", "また"]
        uC = ["今日", "も", "また", "俺は"]
        uD = ["今日", "も", "また", "俺は", "元気"]
        chiA = rest.getChildofForrowedU(uA)
        chiB = rest.getChildofForrowedU(uB)
        chiC = rest.getChildofForrowedU(uC)
        chiD = rest.getChildofForrowedU(uD)

        chiA.toPrint()
        chiB.toPrint()
        chiC.toPrint()
        chiD.toPrint()

        result = []
        result.append(chiA.getNumofChilds())
        result.append(chiB.getNumofChilds())
        result.append(chiC.getNumofChilds())
        result.append(chiD.getNumofChilds())

        # (今日も            )  の子は  (また)
        # (今日もまた        )  の子は  (人が,俺は)
        # (今日もまた俺は    )  の子は  (元気,残業)
        # (今日もまた俺は元気)  の子は いない
        expected = [1, 2, 2, 0]
        self.assertEqual(expected, result)
Example #21
0
def genRestaurant(ID, name, postcode, lng, lat, rating, vicinity, _type,
                  cuisines, photos, times):
    if (_type == 'bar') or (_type == 'restaurant'):
        alcohol = True
        byo = True
    else:
        alcohol = random.choice([True, False])
        byo = random.choice([True, False])
    wheelchair = random.choice([True, False])
    wifi = random.choice([True, False])
    pets = random.choice([True, False])
    card = random.choice([True, False])
    music = random.choice([True, False])
    tv = random.choice([True, False])
    parking = random.choice([True, False])

    deals = []
    for i in range(5):
        if random.choice([True, False]):
            deals.append(random.choice(Deals[i * 3:i * 3 + 2]))
    return Restaurant(ID, name, postcode, lng, lat, rating, vicinity, _type,
                      cuisines, alcohol, byo, wheelchair, wifi, pets, card,
                      music, tv, parking, photos, times, deals)
Example #22
0
    def test_isCollectEliminate(self):

        # なぜか思考ごとに結果が変わるという場合があったので
        # 100回くらい試行して全部 OK の場合のみ OK とする
        flag = True
        for _ in range(100):
            # 根店を生成
            rest = Restaurant.Restaurant(None, [])
            # 文脈を適当に挿入

            u1 = ["きしむ", "ベッド", "の", "上で"]
            u2 = ["優しさ", "を", "持ち寄り"]
            rest.addCustomerfromSentence(u1)
            rest.addCustomerfromSentence(u2)
            before = rest.toJSON()

            # print("BEFORE ADDING u3")
            # rest.toPrint()

            u3 = ["きつく", "身体", "抱きしめあえば"]
            rest.addCustomerfromSentence(u3)
            # print("AFTER  ADDING u3")
            # rest.toPrint()

            rest.eliminateCustomerfromSentence(u3)
            after = rest.toJSON()

            # print("AFTER  ELIMINATING u3")
            # rest.toPrint()
            flag = flag and (before == after)
            if before != after:
                print("after is different before:")
                print("before:" + str(before))
                print("after :" + str(after))
                break

        self.assertTrue(flag)
Example #23
0
import simpy
import random
import Restaurant

DAYS = 7
SIM_TIME = DAYS * 24 * 60  # sim time in minutes
RANDOM_SEED = 1

print('Restaurant')
random.seed(RANDOM_SEED)

env = simpy.Environment()
env.process(
    Restaurant.setup(env=env, num_servers=5, serve_time=1, lambda_arr_rate=10))

env.run(until=SIM_TIME)
print('Restaurant results after %s days' % DAYS)
Example #24
0
File: foodr.py Project: cjoy/foodr
            "Fish and Chips", "Frozen Yogurt", "Grill", "Ice Cream", "Juice",
            "Kebabs", "Noodles", "Pastry", "Pho", "Pizza", "Ramen", "Sandwich", "Seafood",
            "Steakhouse", "Sushi", "Tapas", "Teppanyaki", "Teriyaki", "Yum Cha"]
Types = ["bar", "bakery", "cafe", "restaurant", "meal_takeaway", "meal_delivery"]
Liked = []

# load restaruants from static json data using the restaraunts model
local_data = os.path.join(app.static_folder, 'data/restaurant.json')
with open(local_data) as f:
    lines = json.load(f)
    data = lines["Restaurants"]

    for r in data:
        Restaurants.append(Restaurant(r['id'], r['name'], r['postcode'], r['lng'], r['lat'], r['rating'],
                                      r['vicinity'], r['type'], r['cuisines'], str(r['alcohol']).lower(),
                                      str(r['byo']).lower(), str(r['wheelchair']).lower(), str(r['wifi']).lower(),
                                      str(r['pets']).lower(), str(r['card']).lower(), str(r['music']).lower(),
                                      str(r['tv']).lower(), str(r['parking']).lower(), r['photos'],
                                       r['times'], r['deals']))

@app.route('/')
def start():
    query = request.args.get('q')
    return render_template('foodr/index.html', query=query, restaurants=Restaurants, cuisines=Cuisines, types=Types)

@app.route('/search')
def search():
    query = request.args.get('q')
    #linear search: append restaurants that contains the query
    results = [[] for x in xrange(26*9)]
    count = 0
    if query != "":
Example #25
0
#-*- coding: utf-8 -*-

import Restaurant

print("Start Parsing Test")

rest = Restaurant.Restaurant(None, [])

u = []

with open("HPYLM/tasks/inputSentences.txt", "r") as f:
    line = f.readline()
    while (line != ""):
        u.append([line[:-1]])
        line = f.readline()

print("input sentences:")
for s in u:
    print(s[0])

result = rest.executeParsing(u, 100000)

print("parsing results:")
with open("tasks/result.txt", "w") as f:
    for r in result:
        line = ""
        for w in r:
            line = line + w + ", "
        line = line + "\n"
        print(line)
        f.write(line)
Example #26
0
def main():

    iterations = 20  # default
    if len(sys.argv) == 2:
        iterations = int(sys.argv[1])
    print("Iterations: ")
    print(iterations)

    init()
    #-------------------------------
    # Initialisation
    #-------------------------------
    nbLignes = game.spriteBuilder.rowsize
    nbColonnes = game.spriteBuilder.colsize
    print("lignes", nbLignes)
    print("colonnes", nbColonnes)

    players = [o for o in game.layers['joueur']]
    nbPlayers = len(players)

    # on localise tous les états initiaux (loc du joueur)
    initStates = [o.get_rowcol() for o in game.layers['joueur']]

    # on localise tous les objets  ramassables (les restaurants)
    goalStates = [o.get_rowcol() for o in game.layers['ramassable']]
    restaurants = [Restaurant(coord) for coord in goalStates]

    # on localise tous les murs
    wallStates = [w.get_rowcol() for w in game.layers['obstacle']]

    # on liste toutes les positions permises pour les joueurs #
    allowedStates = list(product(range(nbLignes), range(nbColonnes)))

    for x, y in set(chain(wallStates, goalStates)):
        allowedStates.remove((x, y))

    # creating one Strategy object
    nearestStrategy = LOR(restaurants)
    randomStrategy = RandomStrategy(restaurants)

    # Converting players to AdaptedPlayers and creating teams
    for j in range(nbPlayers // 2):
        players[j] = AdaptedPlayer(players[j], initStates[j], nearestStrategy,
                                   goalStates, wallStates)
        game.mainiteration()

    team_a = Team(players[:nbPlayers // 2])

    for j in range(nbPlayers // 2, nbPlayers):
        players[j] = AdaptedPlayer(players[j], initStates[j], randomStrategy,
                                   goalStates, wallStates)
        game.mainiteration()

    team_b = Team(players[nbPlayers // 2:])

    teams = [team_a, team_b]

    # Creating a simulation that will play the game multiple times
    s = Simulation(game, restaurants, teams, allowedStates, initStates,
                   iterations)
    s.set_speed(2000)
    s.play(1000, no_rest=True
           )  # no_rest just for not slowing down the game when we reset it
    s.summary()

    pygame.quit()
Example #27
0
# import Restaurant
from Restaurant import*

ret = Restaurant("fdefe", 'fewfew')
ret.describe_restaurant()

ince = IceCreamStand("dew", "dwe", "dw")
ince.describe_restaurant()


Example #28
0
from flask import Flask, render_template, request
from sqlite import create_table, data_entry, pull_img_from_db, pull_moreInfo_from_db
from Restaurant import *

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')


# create_table()

lonasLilEats = Restaurant(
    "Lonas LiL Eats", "/static/images/lonas-lil-eats.jpg",
    "https://www.google.com/search?q=lonas+lil+eats&rlz=1C5CHFA_enUS855US855&oq=lonas&aqs=chrome.0.69i59j69i57j69i59j0l2j69i60l3.1335j0j7&sourceid=chrome&ie=UTF-8"
)
vpSqaure = Restaurant(
    "VP Square", "/static/images/vp-sqaure.jpg",
    "https://www.google.com/search?q=vp+square&rlz=1C5CHFA_enUS855US855&oq=vp+square&aqs=chrome..69i57j0l5j69i60l2.2166j0j9&sourceid=chrome&ie=UTF-8"
)
copperPig = Restaurant(
    "Copper Pig", "/static/images/copper-pig.jpg",
    "https://www.google.com/search?rlz=1C5CHFA_enUS855US855&sxsrf=ALeKk00mDPkZaJA3TRyBIQRvE4E34wwPzg%3A1582071238196&ei=xn1MXpjAC4GztAaUxYXYDA&q=copper+pig&oq=copper+pig&gs_l=psy-ab.3..35i39l3j0l7.498.1067..1575...0.2..0.79.297.4......0....1..gws-wiz.......0i71j0i22i30j0i22i10i30j38j0i20i263.6YitLadtfJU&ved=0ahUKEwiYu6XRqtznAhWBGc0KHZRiAcsQ4dUDCAs&uact=5"
)
mochiCafe = Restaurant(
    "Mochi Cafe", "/static/images/mochi-cafe.jpg",
    "https://www.google.com/search?rlz=1C5CHFA_enUS855US855&sxsrf=ACYBGNT1o3smbc6gl43gu1F2_hNFgOTRPA%3A1582071240870&ei=yH1MXpTgNNOQtAbnjaPoAw&q=mochi+cafe&oq=mochi+cafe&gs_l=psy-ab.3..35i39j0l6j0i22i30l3.11857.12792..13021...0.4..0.97.735.10......0....1..gws-wiz.......0i71j0i67j0i273j0i10j0i131.mjj5-YTp3VM&ved=0ahUKEwiU5MjSqtznAhVTCM0KHefGCD0Q4dUDCAs&uact=5"
)
# southwestMarket = Restaurant("Southwest Market", "southwest-market.jpg", "https://www.google.com/search?q=southwest+market&rlz=1C5CHFA_enUS855US855&oq=south&aqs=chrome.0.69i59j69i57j35i39j0l2j69i60l3.986j0j7&sourceid=chrome&ie=UTF-8")
__author__ = 'sony'

#Restaurant Problem

#Run this file

from Guest import *
from Restaurant import *

print("Enter restaurant size")
nSizeInput=int(input()) #Taking input from user for restaurant size
R = Restaurant(nSizeInput) #Making a restaurant with given restaurant size

print("Enter number of guests in a restaurant") #Asking user to enter number of guests in the restaurant
nNumberGuests=int(input())
#Creating a list of guests; asking user for name and hungervalue of guests
listGuest=[None]*nNumberGuests
for l in range(nNumberGuests):
    print("Enter name of guest",l+1)
    chGuestName=input()
    print("Enter hunger value of guest",l+1)
    nGuestHunger=int(input())
    listGuest[l] =Guest(chGuestName,nGuestHunger)

#Loop to seat the guests and serve them in the restaurant
bAvailable=True 
j=0
while(j<3):
    bAvailable= R.seat(listGuest[j])
    R.serve()
    if (bAvailable==True):
Example #30
0
import Restaurant as r

rest = r.Restaurant("Naan & Curry", "Indian")

print(rest.restaurant_name)

print(rest.cuisine_type)

rest.describe_restaurant()

rest.open_restaurant()

rest.set_number_served(92)

rest.describe_restaurant()

rest.increment_number_served(10)

rest.describe_restaurant()
Example #31
0
import Restaurant

test = Restaurant.Restaurant('test12', 'Chinese')
test.describe_restaurant()
test.open_restaurant()
Example #32
0
import Dog as D
import Student as Stu
import Restaurant as Res
my_dog = D.Dog("二哈", 5)
my_dog.sit()
my_dog.show()
my_dog.roll_over()

count = [x for x in range(0, 5)]
dogs = []
for v in count:
    dogs.append(D.Dog("name_" + str(v), v))

a = 0
for d in dogs:
    print(d.name)
    a += d.age
print(a)
print("===============")
s = Stu.Student("zzl", '男', 35)
s.print_stu_info()
s.study('Chinese', 'English', 'French')
print("===========")
s.study()
print("==============")
r = Res.Restaurant("福味居", "粤菜")
r.open_restaurant()
r.describe_restaurant()
r.close_restaurant()
Example #33
0
 def RunTest(self):
     TestR=Restaurant(2)
     guest=Guest('Mary',3)
     TestR.seat(guest)
     TestR.serve()
     assert guest.nHungerValue==2,'incorrect serving function'
     guest1=Guest('John',2)
     TestR.seat(guest1)
     TestR.serve()
     assert guest.nHungerValue==1,'incorrect serving function'
     TestR.serve()
     assert guest.nHungerValue==0,'incorrect serving function'
     guest2=Guest('Alice',1)
     TestR.seat(guest2)
     TestR.serve()
     assert guest2.nHungerValue==0,'incorrect serving function'
     print("Test of serving function is successful")
#Christian Flores 14/02/2021

import Restaurant

restaurant_Corleone = Restaurant.Restaurant("Corleone", "Pizza")
restaurant_McDonalds = Restaurant.Restaurant("McDonalds", "Hamburguers")
restaurant_Breakfast = Restaurant.Restaurant("Brkfast", "Breakfast")

restaurant_Corleone.describe_restaurant()
restaurant_McDonalds.describe_restaurant()
restaurant_Breakfast.describe_restaurant()