Skip to content

Instantly share code, notes, and snippets.

View rudaoshi's full-sized avatar

孙明明 rudaoshi

  • KnowledgeFrontier
View GitHub Profile
@eamartin
eamartin / benchmark.py
Created August 10, 2011 09:10
Python JSON Benchmark
'''cjson, jsonlib, simplejson, and yajl also use C code
demjson did not use C code, but was too painfully slow to benchmark
(took about 20 seconds for these tests)
'''
import json
import sys
import time
with open('doc.json') as f:
@e-mon
e-mon / wn3.1.py
Created April 24, 2015 03:15
WordNet in NLTK version up from 3.0 to 3.1
import os
nltkdata_wn = '/path/to/nltk_data/corpora/wordnet/'
wn31 = "http://wordnetcode.princeton.edu/wn3.1.dict.tar.gz"
if not os.path.exists(nltkdata_wn+'wn3.0'):
os.mkdir(nltkdata_wn+'wn3.0')
os.system('mv '+nltkdata_wn+"* "+nltkdata_wn+"wn3.0/")
if not os.path.exists('wn3.1.dict.tar.gz'):
os.system('wget '+wn31)
os.system("tar zxf wn3.1.dict.tar.gz -C "+nltkdata_wn)
@udibr
udibr / beamsearch.py
Last active October 4, 2021 11:50
beam search for Keras RNN
# variation to https://github.com/ryankiros/skip-thoughts/blob/master/decoding/search.py
def keras_rnn_predict(samples, empty=empty, rnn_model=model, maxlen=maxlen):
"""for every sample, calculate probability for every possible label
you need to supply your RNN model and maxlen - the length of sequences it can handle
"""
data = sequence.pad_sequences(samples, maxlen=maxlen, value=empty)
return rnn_model.predict(data, verbose=0)
def beamsearch(predict=keras_rnn_predict,
@MarchLiu
MarchLiu / elements.json
Created July 4, 2016 13:02
Euclid's Elements relations. Each json item for each element.
{"name":"C.N.1","description":"Things which are equal to the same thing are also equal to one another.","references":[]}
{"name":"C.N.2","description":"If equals be added to equals, the wholes are equal.","references":[]}
{"name":"C.N.3","description":"If equals be subtracted from equals, the remainders are equal.","references":[]}
{"name":"C.N.4","description":"Things which coincide with one another are equal to one another.","references":[]}
{"name":"C.N.5","description":"The whole is greater than the part.","references":[]}
{"name":"Def.1.1","description":"A point is that which has no part.","references":[]}
{"name":"Def.1.10","description":"When a straight line set up on a straight line makes the adjacent angles equal to one another, each of the equal angles is right, and the straight line standing on the other is called a perpendicular to that on which it stands.","references":[]}
{"name":"Def.1.11","description":"An obtuse angle is an angle greater than a right angle.","references":[]}
{"name":"Def.1.12
@ChenyangGao
ChenyangGao / qrcode_cookie_115
Last active July 19, 2024 03:01
115扫码登录,可选择 app,获取 cookie