pip install namedentities
(You may need to prefix this with "sudo " to authorize installation.)
NOTA BENE Code runs successfully under Python 3, but packaging seemingly doesn't work as yet.
from namedentities import named_entities u = u'both em\u2014and–dashes…' print named_entities(u)
from namedentities import named_entities u = 'both em\u2014and–dashes…' print(named_entities(u))
1.0.8 No longer attempts to encode <, >, or & (or thier numerical equivalents) to avoid interfering with HTML escaping.
This is basically a packaging of Ian Beck's work (described in http://beckism.com/2009/03/named_entities_python/)
Thank you, Ian!