def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
python类org()的实例源码
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
relextract.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
util.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 29
收藏 0
点赞 0
评论 0
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
def descape_entity(m, defs=htmlentitydefs.entitydefs):
"""
Translate one entity to its ISO Latin value.
Inspired by example from effbot.org
"""
#s = 'mcglashan_&_sarrail'
#l = ['mcglashan', '&', 'sarrail']
#pattern = re.compile("&(\w+?);")
#new = list2sym(l)
#s = pattern.sub(descape_entity, s)
#print s, new
try:
return defs[m.group(1)]
except KeyError:
return m.group(0) # use as is
def _show_plot(x_values, y_values, x_labels=None, y_labels=None):
try:
import matplotlib.pyplot as plt
except ImportError:
raise ImportError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
plt.locator_params(axis='y', nbins=3)
axes = plt.axes()
axes.yaxis.grid()
plt.plot(x_values, y_values, 'ro', color='red')
plt.ylim(ymin=-1.2, ymax=1.2)
plt.tight_layout(pad=5)
if x_labels:
plt.xticks(x_values, x_labels, rotation='vertical')
if y_labels:
plt.yticks([-1, 0, 1], y_labels, rotation='horizontal')
# Pad margins so that markers are not clipped by the axes
plt.margins(0.2)
plt.show()
#////////////////////////////////////////////////////////////
#{ Parsing and conversion functions
#////////////////////////////////////////////////////////////
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)
util.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)
def __getattr__(self, attr):
# Fix for inspect.isclass under Python 2.6
# (see http://bugs.python.org/issue1225107).
# Without this fix tests may take extra 1.5GB RAM
# because all corpora gets loaded during test collection.
if attr == '__bases__':
raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
self.__load()
# This looks circular, but its not, since __load() changes our
# __class__ to something new:
return getattr(self, attr)