Esempio n. 1
0
def submit():
    page_data = request.json

    user_submission = page_data["user_subm"]
    annotate_subm = render_text(scorer.nlp(user_submission))
    word = page_data["word"]

    mask = scorer.nlp_data['title'] == word
    definition = scorer.nlp_data.loc[mask]['nlp_doc'].values[0]
    definition = scorer.get_first_sent(definition)
    annotate_def = render_text(definition)
    href = scorer.nlp_data.loc[mask]['href'].values[0]

    url = baseurl + href

    score = scorer.score(word, user_submission)
    submission = render_template('annotate-submission.html',
                                 data=Markup(annotate_subm))
    answer = render_template('annotate-definition.html',
                             data=Markup(annotate_def),
                             url=url)
    show_score = render_template('score.html', data=score)

    leaderboard = scorer.nlp_data.loc[mask]['leaderboard'].values[0]
    show_leaderboard = render_template('leaderboard.html', data=leaderboard)

    next_step = render_template('next_step.html')

    return jsonify({
        'submission': submission,
        'answer': answer,
        'score': show_score,
        'leaderboard': show_leaderboard,
        'next_step': next_step
    })
Esempio n. 2
0
    def draw(self, screen):
        """Draw tiles on the passed screen surface.
        
        Args:
            screen (pygame.Surface): Surface to draw
        """
        pygame.draw.rect(screen, COLORS[self.value], self.cords)

        font_cords = (self.cords[0] + Tile._tile_size // 2,
                      self.cords[1] + Tile._tile_size // 2)
        font_text = str(self.value)

        render_text(screen, font_text, font_cords)
Esempio n. 3
0
def display_score_state(win, ser, score):
    """display_score_state
	
	Args:
	    win (curses window): window for curses, used for debugging dispaly simulation
	    ser (serial monitor object): used for communicating with the board through serial output
	    score (int): score obtained through playing snake

 
	Function used to display the score state after you've died in snake :) 
	Uses function in board_letters.py to retrieve the grid state for each letter in the target message

	"""
    # produce message, display
    message = "Your score: " + str(score)
    render_text(message, ser)

    # Display score only a couple of extra times for extra spice
    time.sleep(1)
    render_text(str(score), ser)
    time.sleep(1)
Esempio n. 4
0
def _add_subtitle_clip(start, end, text):
    temp_file = render_text(text)
    _add_video_clip(
        temp_file,
        t=start,
        duration=end - start,
        pos=("center", 910),
        track="text",
        crossfade=0,
        fadein=0,
        fadeout=0,
        move_playhead=False,
    )
Esempio n. 5
0
        print('Punctuation Key %r (%r)' % (event.keysym, event.char))
    else:
        # f1 to f12, shift keys, caps lock, Home, End, Delete ...
        print('Special Key %r' % event.keysym)


if __name__ == "__main__":

    # initialize Serial monitor
    ser = serial.Serial(port='\\\\.\\COM6',
                        baudrate=115200,
                        parity=serial.PARITY_ODD,
                        stopbits=serial.STOPBITS_ONE,
                        bytesize=serial.EIGHTBITS)

    # for debugging:
    # ser = None
    # update_board_state([[3,5], [3,4], [3,3]] , [5,5])

    # welcome message
    render_text("Welcome To Snake!", ser)

    # game main
    try:
        wrapper(curses_main(ser))
    except:
        render_text("Come back again!", ser)
        pass
    # exit message
    render_text("Come back again!", ser)