Python自然语言处理学习笔记(37):4.9 小结

4.9   Summary 小结

  • Python's assignment and parameter passing use object references; e.g. if a is a list and we assign b = a, then any operation on a will modify b, and vice versa.
  • Python的赋值和传参使用了对象引用;例如,如果a是一个列表并且我们赋值b=a,那么任何对于a的操作将会修改b 的值,反之亦然。
  • The is operation tests if two objects are identical internal objects, while == tests if two objects are equivalent. This distinction parallels the type-token distinction.
  • is操作符测试两个对象是否为同一对象,而==测试两个对象的值是否相等。这区别相对应标记类型的区分。
  • Strings, lists and tuples are different kinds of sequence object, supporting common operations such as indexing, slicing, len(), sorted(), and membership testing using in.
  • 字符串,列表和元组是不同种类的序列对象,支持如indexing, slicing, len(), sorted()以及成员测试in等一般操作。
  • We can write text to a file by opening the file for writing ofile = open('output.txt', 'w'), then adding content to the file ofile.write("Monty Python"), and finally closing the file ofile.close().
  • 通过打开文件用以写入ofile = open('output.txt', 'w')的方式,我们可以将文本写入到文件,然后增加内容到文件ofile.write("Monty Python"),最后关闭文件ofile.close().
  • A declarative programming style usually produces more compact, readable code; manually-incremented loop variables are usually unnecessary; when a sequence must be enumerated, use enumerate().
  • 声明式编程风格常常产生更简洁,可读性更好的代码;手动增加的循环变量常常是不需要得;当一个序列必须被枚举时,使用enumerate()
  • Functions are an essential programming abstraction: key concepts to understand are parameter passing, variable scope, and docstrings.
  • 函数是一个基本的编程抽象:主要概念要理解传参,变量范围,文档字符串。
  • A function serves as a namespace: names defined inside a function are not visible outside that function, unless those names are declared to be global.
  • 函数作为一个名称空间:在函数内部定义的名称从外部不能访问,除非那些成为被声明为global
  • Modules permit logically-related material to be localized in a file. A module serves as a namespace: names defined in a module — such as variables and functions — are not visible to other modules, unless those names are imported.
  • 模块允许逻辑相关的材料被放置在一个文件内。模块作为一个名称空间:定义在模块中的名称—诸如变量和函数—对于其他模块来说是不可见的,除非这些名称被导入。
  • Dynamic programming is an algorithm design technique used widely in NLP that stores the results of previous computations in order to avoid unnecessary recomputation.
  • 动态编程是广泛地应用在NLP中的一个算法设计技术,它存储先前计算结构以避免不必要的重新计算。

posted @ 2011-08-21 15:09  牛皮糖NewPtone  阅读(425)  评论(0编辑  收藏  举报