This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
term<-c("egypt","jordan","israel","saudi") | |
term_vec<-foreach(i=1:length(all_score_frames),.combine=rbind) %do% | |
{ | |
score_row<-rep(0,length(term)) | |
for(z in 1:length(score_row)) | |
{ | |
sel_score<-all_score_frames[[i]][all_score_frames[[i]]$term==term[z],"score"] | |
sel_score[is.na(sel_score)]<-0 | |
if(length(sel_score)==0) | |
sel_score<-0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuerySignatureV1AuthHandler(QuerySignatureHelper, AuthHandler): | |
""" | |
Provides Query Signature V1 Authentication. | |
""" | |
SignatureVersion = 1 | |
capability = ['sign-v1', 'mturk'] | |
def _calc_signature(self, params, *args): | |
boto.log.debug('using _calc_signature_1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuerySignatureV1AuthHandler(QuerySignatureHelper, AuthHandler): | |
""" | |
Provides Query Signature V1 Authentication. | |
""" | |
SignatureVersion = 1 | |
capability = ['sign-v1', 'mturk'] | |
def _calc_signature(self, params, *args): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from copy import deepcopy | |
def invert(X): | |
""" | |
Invert a matrix X according to gauss-jordan elimination | |
In gauss-jordan elimination, we perform basic row operations to turn a matrix into | |
row-echelon form. If we concatenate an identity matrix to our input | |
matrix during this process, we will turn the identity matrix into our inverse. | |
X - input list of lists where each list is a matrix row | |
output - inverse of X | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
from nltk.tokenize.punkt import PunktSentenceTokenizer | |
from sklearn.feature_extraction.text import TfidfTransformer, CountVectorizer | |
SENTENCES_IN_SUMMARY = 10 | |
MIN_SENTENCE_LENGTH = 50 | |
MAX_SENTENCE_LENGTH = 200 | |
def f7(seq): | |
seen = set() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from queue.models import Submission | |
import queue | |
subs = Submission.objects.filter(queue_name="open-ended", retired=False) | |
queue_name="open-ended" | |
for sub in subs: | |
qitem=str(sub.id) | |
qcount = queue.producer.push_to_queue(queue_name, qitem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Install brew packages (brew-packages.txt) | |
* Setup all packages that need it so that they start at startup | |
* Install pip (easy_install pip) | |
* Install virtualenvwrapper (pip install virtualenvwrapper) | |
* export WORKON_HOME=~/Envs | |
* mkdir -p $WORKON_HOME | |
* source /usr/local/bin/virtualenvwrapper.sh | |
* mkvirtualenv turfly | |
* export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"; | |
psql -d postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
import yaml | |
import textwrap | |
import html2text | |
def write_to_yaml(k, v, yaml_data): | |
if isinstance(v, str): | |
v = v.strip() | |
if v.count("\n") == 0 and k not in ["left_text", "initial_display", "hint", "answer", "check_val", "imports", "instructions"]: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def code_filter(code): | |
""" | |
Filters out low quality training code, with an aim to improving benchmark performance. Works best with Python. | |
""" | |
# Python keywords | |
keywords = ["assert", "async", "await", "break", "class", "continue", "def", "del", "elif", "else", "except", | |
"finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "nonlocal", "not", "or", | |
"pass", "raise", "return", "try", "while", "with", "yield"] | |
# This covers single line comments in python + other common languages | |
comment_symbols = ["#", "//"] |
OlderNewer