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
'''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: |
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 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) |
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
# 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, |
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
{"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 |