Skip to content

Instantly share code, notes, and snippets.

@madaan
madaan / depparsing.java
Created October 6, 2014 10:47
Stanford CoreNLP Dependency parsing
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation;
@madaan
madaan / spaceShip_8dir.cpp
Last active August 29, 2015 14:11
SDL2 code for capturing multiple keypresses in one go, based on http://www.programmersranch.com/2014/02/sdl2-keyboard-and-mouse-movement-events.html
#include <SDL.h>
#include <iostream>
using namespace std;
int main(int argc, char ** argv)
{
bool quit = false;
SDL_Event event;
int x = 288;
int y = 208;
@madaan
madaan / 300 topics 5k sentences
Last active August 29, 2015 14:13
100 topics 5k sentences
rrb lrb xinhua aug tuesday wednesday dec official hail
afp lrb rrb 2009 2010 thursday dec friday urgent
particulate level 12 china pollution city reading air quality
stock percent point close share market index exchange higher
say deal source buy march arm asian 35 like
2010 rrb afp saturday lrb feb jan defend 25
year month 15 investment 10 direct foreign consumer 28
guinea country civilian rule african west junta attempt leader
late member early state president 1998 people away counterpart
japan japanese tokyo naoto kan honda yen shed expand
@madaan
madaan / gist:b7d8f0336ca9fe3925d2
Last active August 29, 2015 14:22
Relevant snippet from full inference to show the agreeing k.
/*
* Now start the agreeing k
*/
//Different deltas for different relations
double delta = GoldDbInference.marginMap.get(lrg.relation);
int leastFlips = Integer.MAX_VALUE;
double bestCentralValue = -1;
/**
* Find the optimal central value
*/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Castle Bill Split

  • We have 8 people living in the castle. Thus, the bill gets split in 8 parts.

  • Each part is thus 1/8

  • 4 of these parts are paid by AS. Thus, AS pays 4/8th.

  • Because AS pays 4/8th of the bill, we are left with 4/8th of the bill to pay.

@madaan
madaan / ngram.py
Last active November 18, 2019 05:46
NLTK n-gram model
from nltk.corpus import brown
from nltk.lm import MLE
from nltk import bigrams
from nltk.lm.preprocessing import padded_everygram_pipeline
def get_model(order=2):
lm = MLE(order)
train, vocab = padded_everygram_pipeline(order=2, text=brown.sents())
lm.fit(train, vocab)
return lm
@madaan
madaan / Ref
Created September 18, 2019 05:17
CompareMT Sentence Level BLEU Comparison Issue
and it can be a very complicated thing , what human health is .
and bringing those two together might seem a very daunting task , but what i &apos;m going to try to say is that even in that complexity , there &apos;s some simple themes that i think , if we understand , we can really move forward .
and those simple themes aren &apos;t really themes about the complex science of what &apos;s going on , but things that we all pretty well know .
and i &apos;m going to start with this one : if momma ain &apos;t happy , ain &apos;t nobody happy .
we know that , right ? we &apos;ve experienced that .
and if we just take that and we build from there , then we can go to the next step , which is that if the ocean ain &apos;t happy , ain &apos;t nobody happy .
@madaan
madaan / Best Defaults
Last active October 8, 2019 14:05
HypE Train Log
Training the HypE model...
Number of training data points: 61911
Starting training...
iteration#: 1, loss: 1128.5969721078873
iteration#: 2, loss: 589.3206909894943
iteration#: 3, loss: 352.0712777376175
iteration#: 4, loss: 246.19432146847248
iteration#: 5, loss: 202.48553057014942
iteration#: 6, loss: 165.68770626187325
iteration#: 7, loss: 145.24890618771315