Skip to content

Instantly share code, notes, and snippets.

View ftfarias's full-sized avatar
🎯
Focusing

Felipe Farias ftfarias

🎯
Focusing
  • Data Lead at Alice
  • São Paulo, Brazil
View GitHub Profile
@ftfarias
ftfarias / python_nlp_packages.md
Created October 14, 2019 20:19 — forked from brianspiering/python_nlp_packages.md
A Hacker's Guide to Python string and Natural Language Processing (NLP) packages

A Hacker's Guide to Python string and Natural Language Processing (NLP) packages

Preprocessing

  • The Python Standard Library, especially str.methods and string module are powerful for text processing. Start there.
  • regex - Extends Python's Standard Library re module while being backwards-compatible.
  • chardet - Finds character encoding.
  • ftfy - Take in bad Unicode and output good Unicode. Seriously automagical.
  • ploygot - Helpful for multilingual preprocessing.
@ftfarias
ftfarias / README.md
Created January 24, 2017 23:10 — forked from datagrok/README.md
Circular imports in Python 2 and Python 3: when are they fatal? When do they work?

When are Python circular imports fatal?

In your Python package, you have:

  • an __init__.py that designates this as a Python package
  • a module_a.py, containing a function action_a() that references an attribute (like a function or variable) in module_b.py, and
  • a module_b.py, containing a function action_b() that references an attribute (like a function or variable) in module_a.py.

This situation can introduce a circular import error: module_a attempts to import module_b, but can't, because module_b needs to import module_a, which is in the process of being interpreted.

But, sometimes Python is magic, and code that looks like it should cause this circular import error works just fine!