Skip to content

Instantly share code, notes, and snippets.

@naiaden
naiaden / chunkers.py
Last active March 17, 2022 22:46
Two chunkers for lists
s = [1,5,10,5,10,2000,5,1,2,100_000_000,5,100_000,10]
d = ["asd" * ss for ss in s]
import sys
xx = [sys.getsizeof(x) for x in d]
print(xx)
import more_itertools
def LengthChunker(iterable, length = 5):
return more_itertools.ichunked(iterable, length)
@naiaden
naiaden / diff_mre.py
Created March 21, 2018 14:31
Returns the differences between strings
import difflib
import sys
if len(sys.argv) < 3:
print("Usage: %s string1 string2" % sys.argv[0])
sys.exit()
a = sys.argv[1]
b = sys.argv[2]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@naiaden
naiaden / sentstart.ipynb
Created January 18, 2018 23:49
notebooks
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@naiaden
naiaden / motortest.ino
Last active October 10, 2017 20:18
Kattenvoederautomaat
#include <Adafruit_SoftServo.h> // SoftwareServo (works on non PWM pins)
const int _foodServoPin = 0;
const int _foodButtonPin = 1;
Adafruit_SoftServo foodServo;
int servoAngle = 0;
int foodButtonState = 0;
unsigned long lastServe;
@naiaden
naiaden / huh5
Created October 6, 2017 15:33
Get WER, PPL, INS, DEL, SUB
# full uni
for a in 1; do for l in -50 -20 -10 -5 -4 -3 -2 -1 1 2 3 4 5 10 20 50; do for o in -50 -20 -10 -5 -4 -3 -2 -1 1 2 3 4 5 10 20 50; do mkdir -v /scratch/lonrust/slmout/wat/fulluni-a${a}-l${l}-O${o}; ls -1 /vol/tensusers/lonrust/slm/input/nbest-refs/comp-o | cut -d '.' -f1 | sort -u | parallel --progress --results /scratch/lonrust/slmout/wat/fulluni-a${a}-l${l}-O${o} -j 30 ./asd -i /vol/tensusers/lonrust/speech/comp-o/fulluni --padding -o /scratch/lonrust/slmout/wat/fulluni-a${a}-l${l}-O${o} -r /vol/tensusers/lonrust/slm/input/nbest-refs/comp-o --limit-to {} --debug none -a ${a} -l ${l} -w weighted -m bestinfo --reverse -O ${o}; find /scratch/lonrust/slmout/wat/fulluni-a${a}-l${l}-O${o}/ -name "stdout" | xargs -I {} sh -c 'grep "^fv" {}' > /scratch/lonrust/slmout/wat/fulluni-a${a}-l${l}-O${o}-o.info; done; done; done
echo "ins/del#-50#-20#-10#-5#-4#-3#-2#-1#1#2#3#4#5#10#20#50"; for a in 1; do for l in -50 -20 -10 -5 -4 -3 -2 -1 1 2 3 4 5 10 20 50; do echo -n "$l#"; for o in -50 -20 -10 -5 -4 -3 -2 -1
@naiaden
naiaden / comp-g
Last active March 7, 2017 16:17
reset before new experiment series
for BACKOFF in ngram fullnpref; do for COMP in g; do for PART in aa ab ac ad ae af ag ah ai aj ak al; do echo "./rescore -o /scratch/lonrust/cococpypv3/models/ -m mediargus_4S_W250_t2_T2_s10_p0_v2_train -M nbest-${COMP}-${PART} --testinputfiles /home/lonrust/nbest-comp-files/comp-${COMP}.${PART}.txt -O /scratch/lonrust/cococpypv3/nbest_output/${BACKOFF}/comp-${COMP} -B ${BACKOFF} --debug info"; done; done; done
@naiaden
naiaden / count_backoff.py
Last active December 22, 2016 16:27
Count backoff depth
import sys
unigrams = {}
bigrams = {}
trigrams = {}
quadgrams = {}
with open('/scratch/lonrust/cococpypv3/fixed_derived/1bw_4S_W100_t2_T2_s10_p0_v2_train.copamo.1', 'r') as f:
for line in f:
tokens = line.strip().split("\t")
@naiaden
naiaden / nbest2hyp.py
Last active March 3, 2017 22:35
Determine WER
import sys
from operator import itemgetter
from os import listdir
from os.path import isfile, join
nbest_path = sys.argv[1]#"/scratch/lonrust/cococpypv3/input/nbest/comp-c"
output_path = sys.argv[2]#"/scratch/lonrust/cococpypv3/nbest_rescored/comp-c"
@naiaden
naiaden / fullrun.sh
Last active November 9, 2016 15:57
preprocessing
export W=2
export T=2
export t=2
export SAMPLES=10
export DOMAIN=$(dnsdomainname)
if [ ${DOMAIN} = "science.ru.nl" ]; then
OUTPUTPREFIX=/scratch/lonrust/cococpypv3
COCOCPYPPREFIX=/home/lonrust/Software/cococpyp