Skip to content

Instantly share code, notes, and snippets.

View benui-dev's full-sized avatar
🌱

benui benui-dev

🌱
View GitHub Profile
# Bayesian Inference with Tears
# This is some simple code that I made from the Italian/Japanese food example
# at the end of http://www.isi.edu/natural-language/people/bayes-with-tears.pdf
import random
counts = {
"japanese" : 0,
"italian" : 1, # Force the first day to be Italian
}
@benui-dev
benui-dev / chinese_restaurant.py
Created June 16, 2011 07:37
Chinese Restaurant process in Python
import random
# Play with different concentrations
for concentration in [0.0, 0.5, 1.0]:
# First customer always sits at the first table
# To do otherwise would be insanity
tables = [1]
# n=1 is the first customer
@benui-dev
benui-dev / gist:1170054
Created August 25, 2011 05:35
KDict dictionary entry draft
entry: {
korean: '먹다',
pronunciation: '먹다', // fill programmatically
hanja: '食', // Differentiate between yet-to-be-filled and explicitly NO hanja, it's a Korean/non-Chinese word
difficulty: 4, // int
frequency: 24, // should be a relative number, NOT a rank, as zipf distribution of words makes rank meaningless
definitions: {
english: [
'to eat', // Should Verbs in English have "to" prefix?
'to drink'
@benui-dev
benui-dev / gist:1196227
Created September 6, 2011 00:12
KDict version example with rollback information
{
_id : 52512451,
changes: {
before: {
1234567: { "korean.word": "", "pos": 1 },
1234568: { "definitions.english": "chees" }
},
after: {
1234567: { "korean.word": "음악", "pos": 2 },
1234568: { "definitions.english": "cheese" }
@benui-dev
benui-dev / gist:1196229
Created September 6, 2011 00:13
KDict version example without rollback information
{
_id : 52512451,
changes: {
1234567: { "korean.word": "음악", "pos": 2 },
1234568: { "definitions.english": "cheese" }
},
user: 1232141,
created_at: time
}
# grep :)
people = ['poopy', 'jim', 'sarah', 'poopsmith', 'aki']
friends = (person for person in people when !person.match(/poop/))
alert friends
@benui-dev
benui-dev / gist:1255492
Created October 1, 2011 02:03
Vows-bdd example
Feature("Creating a User")
.scenario("Create a User via Form")
.given "the server is running", ->
server.ready @callback
.and "the DB is popuplated", ->
setupFixtures @callback
.when "I visit the form at user/new", ->
@benui-dev
benui-dev / gist:1402971
Created November 29, 2011 01:44
import
$ ./mongoimport --file ~/ribes/ntcir-min.json -c ej --drop
connected to: 127.0.0.1
dropping: test.ej
imported 3 objects
@benui-dev
benui-dev / gist:1402974
Created November 29, 2011 01:45
mongodb
$ ./mongo
MongoDB shell version: 2.0.0
connecting to: test
> db
test
> db.ej.count()
2
@benui-dev
benui-dev / gist:1402976
Created November 29, 2011 01:45
example data
{ "NICT-ATR" : { "A" : { "adequacy" : 3, "fluency" : 4 }, "B" : { "adequacy" : 3, "fluency" : 3 }, "C" : { "adequacy" : 4, "fluency" : 2 }, "output" : "図12を参照して、本発明の第三実施例に説明説明次に、。" }, "NTT" : { "A" : { "adequacy" : 5, "fluency" : 5 }, "B" : { "adequacy" : 5, "fluency" : 5 }, "C" : { "adequacy" : 5, "fluency" : 5 }, "output" : "次に、 図 12 を参照して、 本発明の第 3 の実施例について説明する。" }, "_id" : { "$oid" : "4ed3428a7f7130fdf093a41d" }, "english" : "Next, explanation will be given on a third embodiment of the present invention, by referring to FIG. 12.", "id" : "20000523-155948-EMBODIMENTS-73", "kuro" : { "A" : { "adequacy" : 5, "fluency" : 5 }, "B" : { "adequacy" : 5, "fluency" : 5 }, "C" : { "adequacy" : 5, "fluency" : 5 }, "output" : "次に、本発明の第3の実施例について12図である参照して説明する。" }, "moses" : { "A" : { "adequacy" : 5, "fluency" : 5 }, "B" : { "adequacy" : 5, "fluency" : 5 }, "C" : { "adequacy" : 5, "fluency" : 5 }, "output" : "次に 、 図 12 を 参照 し て 、 本 発明 の 第 3 実施 例 について 説明 する 。 " }, "ref" : "次に、本発明の第3実施例を図12用いて説明する。", "tsbmt" : { "A" : { "a