Skip to content

Instantly share code, notes, and snippets.

View felixpeters's full-sized avatar

Felix Peters felixpeters

View GitHub Profile
@felixpeters
felixpeters / tweetPreprocessor.py
Created January 4, 2018 17:05
Tweet preprocessor for the GloVe Twitter embedding
import re
def hashtag_repl(hashtag):
"""
adds hashtag mark and splits hashtag body on uppercase letters
"""
body = hashtag.group(0)[1:]
if body.upper() == body:
result = '<hashtag> ' + body + ' <allcaps>'
else:
@felixpeters
felixpeters / min-char-rnn.py
Created December 4, 2017 07:52 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)