Apr 29, 2015
Apr 16, 2015
[Python] defaultdict will not always generate default value
If you didn't assign default data type, then the defaultdict will not generate a default value for a missing key. For this case, we can use get(key) to find the key value and it will not cause error if the key is missing. See the following example.
Apr 13, 2015
Using the Stanford parse tree through NLTK
This is a note for using the Stanford parse tree through NLTK.
Environment setup:
http://stackoverflow.com/questions/13883277/stanford-parser-and-nltk
Stanford parse tree module:
http://nlp.stanford.edu/software/lex-parser.shtml#Download
Remember to update the JRE and JDK to the version you need.
Manual for commands:
http://www.nltk.org/api/nltk.parse.html#module-nltk.parse.stanford
http://www.nltk.org/_modules/nltk/tree.html
Environment setup:
http://stackoverflow.com/questions/13883277/stanford-parser-and-nltk
Stanford parse tree module:
http://nlp.stanford.edu/software/lex-parser.shtml#Download
Remember to update the JRE and JDK to the version you need.
Manual for commands:
http://www.nltk.org/api/nltk.parse.html#module-nltk.parse.stanford
http://www.nltk.org/_modules/nltk/tree.html
Apr 12, 2015
int is not an object in Java
Type int in Java is not an object. So when we assign a previously created int variable to another newly created int variable, they are not sharing the same memory (they are mutually independent).
Unlike type int, String is an object in Java. When we assign a previously created string assigned to another newly created string, they share the same object.
PS. String is not mutable.
Apr 4, 2015
[Python] Counter
The function of "Counter" make it very convenient to count the number of repeated items in two list. See the following example.
Apr 3, 2015
[Python] some operations on list
When using a list in Python, we can see the indicator of the items as follows:
x = [0, 1, 2, 3, 4, 5, 6, 7, 8]
x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8]
x[-0], x[-8], x[-7], x[-6], x[-5], x[-4], x[-3], x[-2], x[-1] <= reverse direction
x[-9]
some usages of list in Python are shown below:
x = [0, 1, 2, 3, 4, 5, 6, 7, 8]
x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8]
x[-0], x[-8], x[-7], x[-6], x[-5], x[-4], x[-3], x[-2], x[-1] <= reverse direction
x[-9]
some usages of list in Python are shown below:
Subscribe to:
Posts (Atom)