本文整理匯總了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()