This file contains 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
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}" |
This file contains 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
<script type="text/javascript"> | |
jQuery(function(){ | |
$('.hoverable span').hide(); | |
$('.hoverable a').hover( | |
function(){$(this).next().show()}, | |
function(){$(this).next().hide()} | |
) | |
This file contains 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
#!/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." |
This file contains 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
#!/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 } |
This file contains 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
#!/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 = {} |
This file contains 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
#!/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] |
This file contains 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
{ | |
"metadata": { | |
"language": "Indonesian", | |
"author": "Sneddon", | |
"date" : "1996", | |
"page" : "237" | |
}, | |
"sentence": "Mereka di Jakarta sekarang.", | |
"translation": "They are in Jakarta now.", | |
"igl": [ |
This file contains 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
/* | |
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: |
This file contains 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
#!/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 |
This file contains 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
#!/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 |
OlderNewer