Skip to content

Instantly share code, notes, and snippets.

View amundo's full-sized avatar
🗿
khagga

Patrick Hall amundo

🗿
khagga
  • Massachusetts
  • 08:06 (UTC -12:00)
View GitHub Profile
require 'net/http'
Net::HTTP.start('en.wikipedia.org') do |http|
response = http.get('/wiki/Harry_Houdini', 'Accept' => 'text/xml')
#Do something with the response.
puts "Code: #{response.code}"
puts "Message: #{response.message}"
puts "Body:\n #{response.body}"
<script type="text/javascript">
jQuery(function(){
$('.hoverable span').hide();
$('.hoverable a').hover(
function(){$(this).next().show()},
function(){$(this).next().hide()}
)
#!/usr/bin/env python
# coding: utf-8
from collections import defaultdict
from operator import itemgetter
"""
The ingredients of a language identification system
The simple system I've built to do language identification
is based on counting two-letter sequences, called
"bigrams."
@amundo
amundo / gist:288282
Created January 27, 2010 23:40
Super short intro to using cosine similarity in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# see http://www.fileslip.net/news/2010/02/04/language-id-project-the-basic-algorithm/
from math import sqrt
you = {'pennies': 1, 'nickels': 2, 'dimes': 3, 'quarters': 4 }
me = {'pennies': 0, 'nickels': 3, 'dimes': 1, 'quarters': 1 }
abby = {'pennies': 2, 'nickels': 1, 'dimes': 0, 'quarters': 3 }
#!/usr/bin/env python
import sys
import codecs
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
content = open(sys.argv[1],'rU').read().decode('utf-8')
letters = list(content)
letterfq = {}
@amundo
amundo / scrabblewords.py
Created February 10, 2010 16:38
find all the words that can be built using the letters in a list, as in Scrabble™.
#!/usr/bin/env python
# coding: utf-8
"""
scrabblewords.py - find all the words that can be built using the letters
in a list, as in Scrabble™.
"""
import codecs
words = codecs.open('/usr/share/dict/words',mode='rU', encoding='utf-8').readlines()
words = [word.strip() for word in words]
{
"metadata": {
"language": "Indonesian",
"author": "Sneddon",
"date" : "1996",
"page" : "237"
},
"sentence": "Mereka di Jakarta sekarang.",
"translation": "They are in Jakarta now.",
"igl": [
/*
invert.js
given two lines of interlinear linguistic annotation on stdin, like:
Ehiwac c-a-kәri sәgәbehem h-ә-k-ec әrɨgeh=i.
spirit:8PL 8PL-R-say spirit:7PL 7PL-R-give-8PL sick=REL
return a data structure like this:
@amundo
amundo / engspan.py
Created November 6, 2010 02:08
an incomplete program for looking for cross-linguistic "minimal pairs" involving English flapped coronals and Spanish [r] between English and Spanish
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
"""
American English flapped /t/ or /d/ (both realized as [ɾ]) might
sound to a Spanish speaker as being closer to a Spanish /r/ than
either Spanish /t/ or /d/ (especially since Spanish /d/ is often
realized as [ð]). Wanted: real English words that would "be" real
@amundo
amundo / cheat_at_scrabble.py
Created March 30, 2011 09:12
A simple tool for finding the highest scoring words with a scrabble rack
#!/usr/bin/env python
# let's cheat at scrabble
def count_letters(word):
count = {}
for letter in word:
if letter not in count: count[letter] = 0
count[letter] += 1
return count