Skip to content

Instantly share code, notes, and snippets.

View HelloAction.java
package edu.cmu.empty;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
@neubig
neubig / identify_japanese_pronouns.py
Created Jun 25, 2019
A script to identify Japanese pronouns
View identify_japanese_pronouns.py
import sys
import re
from collections import defaultdict
# This is a script to identify pronouns in Japanese
# It requires data segmented by KyTea (http://www.phontron.com/kytea/)
#
# If you have raw Japanese text (with no spaces), use this script like:
# cat japanese.txt | kytea | python identify_japanese_pronouns.py > japanese_with_pronouns.txt
#
@neubig
neubig / best-paper-deadline.py
Last active Jul 1, 2020
Best Paper Deadline Time Zone
View best-paper-deadline.py
#### Script to calculate the best paper deadline based on the population on earth based on some not-completely-arbitrary assumptions
# by Graham Neubig
# Results are:
# UTC 8:00 deadline, utility is 1476.1150000000002
# UTC 9:00 deadline, utility is 1438.7800000000002
# UTC 14:00 deadline, utility is 1385.2949999999998
# UTC 15:00 deadline, utility is 1345.945
# UTC 13:00 deadline, utility is 1291.4950000000003
# UTC 7:00 deadline, utility is 1287.1649999999997
@neubig
neubig / petstory.yaml
Created Apr 23, 2019
petstore with oneOf
View petstory.yaml
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
@neubig
neubig / dynet-tagger.py
Last active May 21, 2018
A small sequence labeler in DyNet
View dynet-tagger.py
"""
DyNet implementation of a sequence labeler (POS taggger).
This is a translation of this tagger in PyTorch: https://gist.github.com/hal3/8c170c4400576eb8d0a8bd94ab231232
Basic architecture:
- take words
- run though bidirectional GRU
- predict labels one word at a time (left to right), using a recurrent neural network "decoder"
The decoder updates hidden state based on:
- most recent word
@neubig
neubig / linalg-calcfunction.py
Last active Jul 1, 2020
Examples of linear algebra in numpy
View linalg-calcfunction.py
import numpy as np
import sys
################# Explanation ##################
# This is a function to calculate house prices h(x) = -40 + 0.25x
# The first term (-40) is the base price, and "x" is the number of square feet in the house
################################################
# Set up the function
my_function = np.array([-40, 0.25])
@neubig
neubig / lstm-lm.py
Last active Aug 23, 2017
This is a minimal implementation of training for a language model using long short-term memory (LSTM) neural networks
View lstm-lm.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This is a simplified implementation of the LSTM language model (by Graham Neubig)
#
# LSTM Neural Networks for Language Modeling
# Martin Sundermeyer, Ralf Schlüter, Hermann Ney
# InterSpeech 2012
#
# The structure of the model is extremely simple. At every time step we
@neubig
neubig / plot-gp.py
Created Nov 19, 2014
A simple program to sample functions from a Gaussian process and plot them
View plot-gp.py
#!/usr/bin/python
from math import exp
import numpy as np
import matplotlib.pyplot as plt
def rbf_kernel(x1, x2, variance = 1):
return exp(-1 * ((x1-x2) ** 2) / (2*variance))
def gram_matrix(xs):
@neubig
neubig / pequalnp.py
Last active Aug 29, 2015
This is a program that answers the age-old problem of whether P=NP
View pequalnp.py
#!/usr/bin/python
################################################################################
# pequalnp.py
# Graham Neubig
# 4/1/2014
#
# This is a program that provides an answer for the age-old problem of whether
# the class of problems that can be verified in polynomial time (NP) is equal
# to the class of problems for which an answer can be provided in polynomial
@neubig
neubig / crf.py
Created Nov 7, 2013
This is a script to train conditional random fields. It is written to minimize the number of lines of code, with no regard for efficiency.
View crf.py
#!/usr/bin/python
# crf.py (by Graham Neubig)
# This script trains conditional random fields (CRFs)
# stdin: A corpus of WORD_POS WORD_POS WORD_POS sentences
# stdout: Feature vectors for emission and transition properties
from collections import defaultdict
from math import log, exp
import sys