Skip to content

Instantly share code, notes, and snippets.

View pebbie's full-sized avatar

Peb Ruswono Aryan pebbie

View GitHub Profile
tetangga = {
"1": {"R":"2","D":"3"},
"2": {"L":"1","D":"4"},
"3": {"R":"4","U":"1"},
"4": {"L":"3","U":"2"}
}
def getND(kode,arah):
if arah in tetangga[kode[-1]]:
return kode[:-1]+tetangga[kode[-1]][arah]
@pebbie
pebbie / test_date.py
Created December 15, 2012 14:24
test weekday consistency
import datetime
WEEK = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
def dow(dd,mm,yyyy):
return (datetime.date(yyyy, mm, dd).weekday()+1) % 7
#from python datetimemodule.c
def dow_c(dd, mm, yyyy):
y = yyyy - 1
#
# Panduan Penggunaan pebahasa untuk POS Tagger
#
from hmmtagger import MainTagger
from tokenization import *
mt = None
def init_tag():
global mt
import os, sys
from lxml import etree
from rdflib import ConjunctiveGraph, Namespace, exceptions
from rdflib import URIRef, RDFS, RDF, OWL, BNode, Literal
def get_tag_no_ns(tname):
if "}" in tname:
return tname[tname.index("}")+1:]
else:
"""
Fast non-maximum suppression numpy port
from:
http://quantombone.blogspot.com/2011/08/blazing-fast-nmsm-from-exemplar-svm.html
"""
import numpy as np
"""
author: Peb Ruswono Aryan
date: 20.02.2014
Simple Entity Resolution
read a text file (news) and resolve entities mentioned in the text
uses:
- external Part-of-Speech Tagger API (REST)
- Entity knowledge base over SPARQL with Regex filter
"""
file: html2wikitext.py
author: Peb Ruswono Aryan (28.02.2014)
desc:
script to convert html extracted by [http://github.com/petrabarus/perundangan](perundangan)
into wikitext used in http://hukum.pebbie.org
"""
import re
#!python
"""
game2048.py
bot to play 2048 game by http://gabrielecirulli.com/
as submission for https://www.hackerrank.com/contests/2048-game/challenges/2048
best score 157.2
"""
import copy
import random
import math
@pebbie
pebbie / dump_ckan.py
Created August 13, 2014 21:00
dump all data from ckan website
"""
call : dump_ckan.py <ckan_website>
ckan_website : e.g. http://data.ukp.go.id
author : Peb Ruswono Aryan
"""
from __future__ import print_function
import json
import os
@pebbie
pebbie / rdf2rdf.py
Created September 12, 2014 22:53
rdf-to-rdf format conversion in one line of python code
import sys, rdflib; print rdflib.Graph().parse(sys.argv[1], format=sys.argv[2] if len(sys.argv)>2 else "json-ld").serialize(format=sys.argv[3] if len(sys.argv)>3 else "n3") if len(sys.argv)>1 else "%s <input-file> [<input-format> <output-format>]" % sys.argv[0]