本文整理汇总了Python中photo.Photo.getText方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.getText方法的具体用法?Python Photo.getText怎么用?Python Photo.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类photo.Photo
的用法示例。
在下文中一共展示了Photo.getText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getEventText
# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import getText [as 别名]
def _getEventText(self, event):
"""For a given event, return the text as a list. Note for photo without text,
use a None to hold the place"""
assert self._element_type in Event(event).toDict().keys()
event_text = []
for element in event[self._element_type]:
if self._element_type == "photos":
element = Photo(element)
else:
element = Tweet(element)
try:
if self._is_ascii(element.getText()):
event_text.append(element.getText().lower())
else:
event_text.append("")
except:
event_text.append("")
return event_text
示例2: removeDuplicateElements
# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import getText [as 别名]
def removeDuplicateElements(self):
new_elements = {}
for element in self._event[self._element_type]:
if self._element_type == 'photos':
d = Photo(element)
else:
d = Tweet(element)
key = d.getText() + '|' + d.getUserId()
new_elements[key] = d
self._event[self._element_type] = []
for key, d in new_elements.items():
self._event[self._element_type].append(d)
# need to sort the elements elements or tweets
self.sortElements()