background preloader

Python

Facebook Twitter

Stemming 1.0. Python implementations of various stemming algorithms. Latest Version: 1.0.1 Python implementations of the Porter, Porter2, Paice-Husk, and Lovins stemming algorithms for English. These implementations are straightforward and efficient, unlike some Python versions of the same algorithms available on the Web. This package is an extraction of the stemming code included in the Whoosh search engine. Note that these are pure Python implementations. Stemming algorithms attempt to automatically remove suffixes (and in some cases prefixes) in order to find the "root word" or stem of a given word.

In general porter2 is the best overall stemming algorithm, but not necessarily the fastest or most aggressive. The stemming package contains modules for each algorithm (lovins, paicehusk, porter, and porter2). >> from stemming.porter2 import stem >> stem("factionally") faction The source code for this package is available on BitBucket: Jinja2 (template languate) documentation. Jinja2 is a modern and designer friendly templating language for Python, modelled after Django’s templates. It is fast, widely used and secure with the optional sandboxed template execution environment: <title>{% block title %}{% endblock %}</title><ul>{% for user in users %} <li><a href="{{ user.url }}">{{ user.username }}</a></li>{% endfor %}</ul> Features: sandboxed executionpowerful automatic HTML escaping system for XSS preventiontemplate inheritancecompiles down to the optimal python code just in timeoptional ahead of time template compilationeasy to debug.

Line numbers of exceptions directly point to the correct line in the template.configurable syntax Additional Information If you can’t find the information you’re looking for, have a look at the index or try to find it using the search function: Virtualenv dev documentation. Python v2.7.3 documentation. PEP 8 -- Style Guide for Python Code. Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b.

This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.Comparisons to singletons like None should always be done with is or is not, never the equality operators.Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value.

The other value might have a type (such as a container) that could be false in a boolean context!