Monday, April 2, 2012

Language Models and Python Reflexes

So I burnt slightly more time than necessary on the NLP homework writing my own bigram/unigram calculating code in order to calculate plus one smoothing values on a small corpus.   However it was interesting Python background in terms of the much tripped over integer division issue in Python:

http://stackoverflow.com/questions/1267869/how-can-i-force-division-to-be-floating-point-in-python
http://stackoverflow.com/questions/1282945/python-integer-division-yields-float

As well as an interesting review of the multitude of quick ways to get an item count from a list in Python:

http://stackoverflow.com/questions/2401885/how-to-get-item-count-from-list-in-python
http://stackoverflow.com/questions/3496518/python-using-a-dictionary-to-count-the-items-in-a-list

and my old favorite how to grab a list pairwise in Python:

http://stackoverflow.com/questions/1257413/iterate-over-pairs-in-a-list-circular-fashion-in-python

No comments: