Skip to content

Instantly share code, notes, and snippets.

View Priyansh2's full-sized avatar
🎯
Focusing

Priyansh Agrawal Priyansh2

🎯
Focusing
View GitHub Profile
###sublime text 3 settings backup
# initialization file (not found)
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@Priyansh2
Priyansh2 / bisect_ngrams.py
Created September 10, 2018 10:59
ngrams and their counts with 'bisect' python2
import bisect
class WordList( object ):
"""Leaf-level is list of words and counts."""
def __init__( self ):
self.words= [ ('\xff-None-',0) ]
def count( self, wordTuple ):
assert len(wordTuple)==1
word= wordTuple[0]
loc= bisect.bisect_left( self.words, word )