Skip to content

Instantly share code, notes, and snippets.

import csv
[…]
with open('sentences.csv', 'rb') as fh:
reader = csv.reader(fh, [… some options might be necessary …])
# at this point `reader` is an iterator that returns tuples
for sentence_id, language, sentence in reader:
if language == 'cmn': # for example, let's print all chinese sentences
print sentence
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@liori
liori / indirect.c
Last active December 20, 2015 12:59
This code does not need a comment.
struct l {
struct l* next;
int value;
};
int main(void) {
struct l elems[300];
int i;
for (i=0; i<300; i++) {
@liori
liori / setcover.mod
Last active December 20, 2015 07:39
Example set-cover implementation in GNU MathProg. Pick the minimal set of sentences which contain all the characters. Run with `glpsol --math setcover.mod --output /dev/fd/0`
set Sentences;
set Characters;
param contains{s in Sentences, c in Characters};
var chosen{s in Sentences} binary;
minimize size: sum{s in Sentences} chosen[s];
s.t. all_characters_covered{c in Characters}: sum{s in Sentences} contains[s, c] * chosen[s] >= 1;
$(document).ready(function() { $('#link_2419545_2267655').data('sentenceId',2419545);$('#link_2419545_2267665').data('translationId',2267665);});