Skip to content

Instantly share code, notes, and snippets.

sub set_default {
my $hashref = shift;
my $k = shift;
my $def = shift;
$hashref->{$k} = $def unless defined $hashref->{$k};
}
@kowey
kowey / gist:769532
Created January 7, 2011 14:48
patch review aliases
take_until_hyphen () {
echo $1 | ghc -e "interact (takeWhile (/= '-'))"
}
darcs_screened_context () {
bname=`basename $1 .dpatch`
darcs get --lazy http://darcs.net/screened --context $1 `take_until_hyphen $bname`
# :-( this ain't git checkout ...
notify-send "context fetched: $bname"
}
@kowey
kowey / notify-long
Created January 10, 2011 11:17
notify-long
#!/bin/bash
CMD=$@
$CMD
STATUS=$?
CMD_SUMMARY=`echo $CMD`
HOSTNAME=`hostname --short`
NOTIFY=notify-send
if [ $STATUS == 0 ]; then
$NOTIFY "DONE: $CMD_SUMMARY ($HOSTNAME)"
else
@kowey
kowey / Makefile
Created January 11, 2011 15:16
Experiments with redo
-include ../../config
define clean-train
cd $(<D) ; $(MOSES_SCRIPTS)/training/clean-corpus-n.perl $(notdir $(basename $<)) en mrl moses-corpus 1 100
mv $(basename $@).en $(basename $@).clean-en
mv $(basename $@).mrl $(basename $@).clean-mrl
endef
ifdef DISABLE_MOSES_TUNING
%/moses-corpus.clean-en : %/trainNdev-full-corpus.en %/trainNdev-full-corpus.mrl
We couldn’t find that file to show.
1.0188729391915491e-5 comprise_vvz v-administrative-area-level3-allerdale
1.035045154780056e-4 shelter_vvg k-administrative-area-level2
1.0437847139195113e-3 transmitter_nn1 v-area-south_central_england
1.0497224601294965e-3 promote_vvn v-classification-xma

This is a DATR file.
Try opening it in various text editors like Gedit or Yudit.

Note: with apologies to Arabic speakers, yes the Arabic bits really are just random characters :-)

Vim seems to less painful to work with (but you have to stomach reading from left to right, which is great for a non-Arabic speaker like me, but I imagine not so fun if you can read Arabic and have to fight your instincts)

% GenI surface realiser
% Copyright (C) 2005 Carlos Areces and Eric Kow
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
module Choice where
data Choice a = Wanted a | Unwanted a
wanted :: Choice a -> Maybe a
wanted (Wanted s) = Just s
wanted (Unwanted _) = Nothing
-- | The item, regardless of whether it's wanted or not
undiscriminate :: Choice a -> a
#!/bin/bash
set -e -o pipefail
pushd `dirname $0` > /dev/null
SCRIPT_DIR=`pwd`
popd > /dev/null
ORIGINALS_DIR=data # treat as read-only!
REFERENCE_DIR=${ORIGINALS_DIR}/hand-extracted
WORK_DIR_SRC=${ORIGINALS_DIR}/document-pairs