def recommend_classroom():
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, 10)
    rooms = get_rooms(3, 10)
    time_string = str(dt.hour) + u'点' + str(dt.minute) + u'分'
    ret = u'现在是' + time_string + u'\n'
    ret += code_building[rooms['building']] \
           + str(rooms['floor']) + u'层第'+ str(class_seq) + u'节空教室较多\n'
    for i in range(3):
        ret += rooms['list'][i]['roomnumber'].split()[0] + '\n'
    ret += u'都是不错的选择'
    return ret
Example #2
0
def get_rooms(least_num, minute_delta):
    room_list = []
    building = ''
    storey = 0
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, minute_delta)
    weekday = datetime.date(dt.year, dt.month, dt.day).weekday()
    while len(room_list) < least_num:
        building = get_building()
        storey = get_storey(building)
        room_list = getclassroomsbyfloor(building, storey, class_seq, weekday)
    return {
        'list': room_list,
        'building': building,
        'floor': storey,
    }
Example #3
0
def recommend_classroom():
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, 10)
    rooms = get_rooms(3, 10)
    if dt.minute < 10 and dt.minute != 0:
        minute_str = '0' + str(dt.minute)
    else:
        minute_str = str(dt.minute)
    time_string = str(dt.hour) + u'点' + minute_str + u'分'
    ret = u'现在是' + time_string + u'\n'
    ret += code_building[rooms['building']] \
           + str(rooms['floor']) + u'层\n第' + str(class_seq) + u'节课空闲教室较多\n'
    for i in range(3):
        ret += rooms['list'][i]['roomnumber'].split()[0] + '\n'
    ret += u'都是不错的选择^_^'
    return ret
Example #4
0
def query_to_dict(query):
    if u'教' in query:
        building_id = toNum(query[query.index(u'教')-1])
    else:
        building_id = 1

    if u'节' in query:
        if query[query.index(u'节')-1] == u'大':
            sequence = toNum(query[query.index(u'节')-2])
        else:
            sequence = toNum(query[query.index(u'节')-1])
    else:
        dt = datetime.datetime.now()
        sequence = getClassSeqNumByDatetime(dt, 20)

    if u'层' in query:
        storey = str(toNum(query[query.index(u'层')-1]))
    else:
        storey = '-'

    if u'天' in query:
        if query[query.index(u'天')-1] == u'后' and query[query.index(u'天')-2] == u'大':
            day_delta = cn_delta[u'大后']
        else:
            day_delta = cn_delta[query[query.index(u'天')-1]]
    else:
        day_delta = 0

    section = ''
    if building_id == 6:
        if u'区' in query:
            section = query[query.index(u'区')-1].upper()
        else:
            section = 'ABC'
    elif building_id == 3:
        if u'段' in query:
            section = str(toNum(query[query.index(u'段')-1]))
        else:
            section = '123'
    building_id = str(building_id) + section
    return {
        'day_delta':   str(day_delta),
        'class_sequence':     str(sequence),
        'building_id': building_id,
        'storey':   storey,
    }
def get_rooms(least_num, minute_delta):
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, minute_delta)
    weekday = datetime.date(dt.year, dt.month, dt.day).weekday()
    building_index = 0
    floors = []
    floor_index = 0
    room_list = []
    while len(room_list) < least_num:
        building_index = random.randint(0, len(buildings) - 1)
        floors = building_storey[buildings[building_index]]
        floor_index = random.randint(0, len(floors) - 1)
        room_list = getclassroomsbyfloor(buildings[building_index], floors[floor_index], class_seq, weekday)
    return {
        'list': room_list,
        'building': buildings[building_index],
        'floor': floors[floor_index]
    }
Example #6
0
def get_rooms2(least_num, minute_delta):
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, minute_delta)
    weekday = datetime.date(dt.year, dt.month, dt.day).weekday()
    building_index = 0
    floors = []
    floor_index = 0
    room_list = []
    while len(room_list) < least_num:
        building_index = random.randint(0, len(buildings) - 1)
        floors = building_storey[buildings[building_index]]
        floor_index = random.randint(0, len(floors) - 1)
        room_list = getclassroomsbyfloor(buildings[building_index], floors[floor_index], class_seq, weekday)
    return {
        'list': room_list,
        'building': buildings[building_index],
        'floor': floors[floor_index]
    }
Example #7
0
def query_to_dict(query):
    if u'教' in query:
        building_id = toNum(query[query.index(u'教') - 1])
    else:
        building_id = 1

    if u'节' in query:
        class_sequence = toNum(query[query.index(u'节') - 1])
    else:
        dt = datetime.datetime.now()
        class_sequence = getClassSeqNumByDatetime(dt, 5)

    if u'层' in query:
        storey = str(toNum(query[query.index(u'层') - 1]))
    else:
        storey = '-'

    if u'天' in query:
        if query[query.index(u'天') - 1] == u'后' and query[query.index(u'天') -
                                                          2] == u'大':
            day_delta = to_delta(u'大后')
        else:
            day_delta = to_delta(query[query.index(u'天') - 1])
    else:
        day_delta = 0

    section = ''
    if building_id == 6:
        if u'区' in query:
            section = query[query.index(u'区') - 1].upper()
        else:
            section = 'ABC'
    elif building_id == 3:
        if u'段' in query:
            section = str(toNum(query[query.index(u'段') - 1]))
        else:
            section = '123'
    building_id = str(building_id) + section
    return {
        'day_delta': str(day_delta),
        'class_sequence': str(class_sequence),
        'building_id': building_id,
        'storey': storey,
    }