Skip to content

Instantly share code, notes, and snippets.

"""A simple implementation of a greedy transition-based parser. Released under BSD license."""
from os import path
import os
import sys
from collections import defaultdict
import random
import time
import pickle
SHIFT = 0; RIGHT = 1; LEFT = 2;
@mnicky
mnicky / mvnc.sh
Created June 4, 2014 12:55 — forked from japgolly/mvnc.sh
#!/bin/bash
RESET="\e[0m"
BLACK="\e[0;30m"
RED="\e[0;31m"
GREEN="\e[0;32m"
YELLOW="\e[0;33m"
BLUE="\e[0;34m"
MAGENTA="\e[0;35m"
CYAN="\e[0;36m"
@mnicky
mnicky / simple_infer.clj
Created June 16, 2012 22:02
Simple inference engine
;simple inference engine, using bruteforce propagation of modus ponens
;if the fact matches given clause (using supplied map of bindings),
;returns a map of established bindings, else returns false
(defn match
([clause fact] (match clause fact {}))
([clause fact bnds]
(let [[cls & clsR] clause, [fct & fctR] fact]
(cond (contains? #{:not=} cls) {:__special__ clause}
(= clause fact) bnds
@mnicky
mnicky / github_lang_chart.sh
Created June 22, 2012 08:30
GitHub programming language popularity chart
# Display chart of programming languages recognized by GitHub, sorted by their popularity.
# Be patient, it takes about one minute to complete on a good internet connection.
for i in `curl -s "https://github.com/languages" | grep -io "/languages/[^\"]*" | sort | uniq`; do curl -s "https://github.com$i" | grep "<h1>.*</h1>" | sed 's/the most/#1/g' | sed 's/.*<h1>\(.*\) <em>.*#\([0-9]*\).*/\2 \1/g'; done | sort -n
@mnicky
mnicky / stopwords-en
Last active October 9, 2015 06:18
Extract words from all your tweets and count their occurences
able
about
above
abst
accordance
according
accordingly
across
act
actually
Rozhovor v kancelárii.
"Čaf. Workuje to?"
"No čau, už si tu? Nie, zatiaľ sa mi to nepodarilo rozbehať."
"Okej, tak sa logofni, ja sa na to luknem."
"Inak júzujem tvoju stoličku, neva? Len si toto sejvnem a hneď ti ju ritarnem. Aj tak to musím ísť dať sajnúť hedovi."
"Kľudne si ju nechaj, tejknem si tamtú."
"Ako chceš, ja už idem za hedom, už si môžeš tejknúť svoju."
U šéfa:
"Šéfko, sajneš mi túto invojsu? Vendor ma už obháňa, že sme overďjú."
@mnicky
mnicky / gist:4027422
Created November 6, 2012 20:48 — forked from jlongster/gist:1712455
traditional lisp macros
;; outlet code for implementing traditional macro expansion
;; macros
(define (expand form)
(cond
((variable? form) form)
((literal? form) form)
((macro? (car form))
(expand ((macro-function (car form)) form)))
;Lisp in Lisp in Golomb forests. Includes use of linked lists.
;Based on Paul Graham's version of McCarthy's paper and code.
;Uses only eq, cond, atom, quote, cons, car, and cdr.
(defun null. (x)
(eq x '()))
(defun and. (x y)
(cond (x
(cond (y 't)
@mnicky
mnicky / lis.py
Created December 10, 2012 20:48
Lispy: Scheme Interpreter in Python
################ Lispy: Scheme Interpreter in Python
## (c) Peter Norvig, 2010; See http://norvig.com/lispy.html
################ Symbol, Env classes
from __future__ import division
Symbol = str
@mnicky
mnicky / lisp_macros.lisp
Created December 11, 2012 21:23
McCarthy's LISP with macros
;source: http://ideone.com/lEx0T
;explanation: http://stackoverflow.com/a/3685147
(defun null. (x)
(eq x '()))
(defun and. (x y)
(cond (x (cond (y 't) ('t '())))
('t '())))