本文整理汇总了Python中textblob.TextBlob.split方法的典型用法代码示例。如果您正苦于以下问题:Python TextBlob.split方法的具体用法?Python TextBlob.split怎么用?Python TextBlob.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类textblob.TextBlob
的用法示例。
在下文中一共展示了TextBlob.split方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_text
# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import split [as 别名]
def get_text(self):
""" NOTE: THIS SHOULD NOT REBUILD DICT EVERY TIME -- REFACTOR """
blob = TextBlob(self.content.decode('utf-8'))
words_ = blob.split()
d = parser.build_ngram_dict(words_)
s = parser.build_sentence(d)
# TODO: add check for max text length
self.text = s
示例2: main
# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import split [as 别名]
def main():
filename = sys.argv[1]
with open(filename) as f:
content = f.read()
blob = TextBlob(content.decode('utf-8'))
words = blob.split()
d = build_ngram_dict(words)
pprint(d)
print()
s = build_sentence(d)
print(s)
if s in content.decode('utf-8'):
print("\nBummer! This sentence is just a copy of one in the corpus.")
示例3: int
# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import split [as 别名]
if __name__=="__main__":
count = 0
days = {}
polarity = {}
num_files = int(sys.argv[1])
#print num_files
for i in range (1,num_files+1):
input_file = open(sys.argv[1+i],'r')
#print i
for line in input_file:
tweet_json = json.loads(line)
tweet = TextBlob(tweet_json['text'])
blob = TextBlob(tweet_json['created_at'])
#print blob
date = blob.split(' ')
day = date[0]
if day == 'Sun':
day = "2016-04-03"
if day == 'Mon':
day = "2016-04-04"
if day == 'Tue':
day = "2016-04-05"
if day == 'Wed':
day = "2016-04-06"
if day == 'Thu':
day = "2016-04-07"
if day == 'Fri':
day = "2016-04-08"
if day == 'Sat':
day = "2016-04-09"