This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from rdflib import Graph, Namespace | |
from rdflib.namespace import RDF, RDFS | |
import requests | |
HYDRA = Namespace("http://www.w3.org/ns/hydra/core#") | |
class HydraOperation: | |
def __init__(self, subj, graph): | |
self.type = graph.value(subj, RDF.type) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rdflib.store import Store | |
from rdflib import Graph, RDF, URIRef, Namespace | |
import urllib.parse as urlparse | |
def add_params(origUrl, paramsDict): | |
url_parts = list(urlparse.urlparse(origUrl)) | |
query = dict(urlparse.parse_qsl(url_parts[4])) | |
query.update(dict([i for i in iter(paramsDict.items()) if i[1] is not None])) | |
url_parts[4] = urlparse.urlencode(query) | |
return urlparse.urlunparse(url_parts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
rastore - virtual RDF data store for rasters | |
a graph interface from a numpy array into RDF Data Cube | |
- shape (dimensions) | |
- element datatype | |
- elements as rdf list? | |
- slices? as structured naming of bnode or a slice object? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
class Rule: | |
def __init__(self, lhs, rhs): | |
self.lhs = lhs | |
self.rhs = rhs | |
def __repr__(self): | |
return "{0} ::== {1}".format(self.lhs, self.rhs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
OlderNewer