本文整理匯總了Python中nltk.compat.TemporaryDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Python compat.TemporaryDirectory方法的具體用法?Python compat.TemporaryDirectory怎麽用?Python compat.TemporaryDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nltk.compat
的用法示例。
在下文中一共展示了compat.TemporaryDirectory方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_textoutput
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_textoutput(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.text.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.text.csv')
json2csv(self.infile, outfn, ['text'], gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例2: test_tweet_metadata
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_tweet_metadata(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.tweet.csv.ref')
fields = ['created_at', 'favorite_count', 'id',
'in_reply_to_status_id', 'in_reply_to_user_id', 'retweet_count',
'retweeted', 'text', 'truncated', 'user.id']
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.tweet.csv')
json2csv(self.infile, outfn, fields, gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例3: test_user_metadata
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_user_metadata(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.user.csv.ref')
fields = ['id', 'text', 'user.id', 'user.followers_count', 'user.friends_count']
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.user.csv')
json2csv(self.infile, outfn, fields, gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例4: test_tweet_hashtag
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_tweet_hashtag(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.hashtag.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.hashtag.csv')
json2csv_entities(self.infile, outfn,
['id', 'text'], 'hashtags', ['text'],
gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例5: test_tweet_usermention
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_tweet_usermention(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.usermention.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.usermention.csv')
json2csv_entities(self.infile, outfn,
['id', 'text'], 'user_mentions', ['id', 'screen_name'],
gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例6: test_tweet_url
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_tweet_url(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.url.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.url.csv')
json2csv_entities(self.infile, outfn,
['id'], 'urls', ['url', 'expanded_url'],
gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例7: test_userurl
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_userurl(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.userurl.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.userurl.csv')
json2csv_entities(self.infile, outfn, ['id', 'screen_name'],
'user.urls', ['url', 'expanded_url'],
gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例8: test_tweet_place
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_tweet_place(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.place.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.place.csv')
json2csv_entities(self.infile, outfn,
['id', 'text'], 'place', ['name', 'country'],
gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例9: test_tweet_place_boundingbox
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_tweet_place_boundingbox(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.placeboundingbox.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.placeboundingbox.csv')
json2csv_entities(self.infile, outfn,
['id', 'name'], 'place.bounding_box', ['coordinates'],
gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)
示例10: test_retweet_original_tweet
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import TemporaryDirectory [as 別名]
def test_retweet_original_tweet(self):
ref_fn = os.path.join(self.subdir, 'tweets.20150430-223406.retweet.csv.ref')
with TemporaryDirectory() as tempdir:
outfn = os.path.join(tempdir, 'tweets.20150430-223406.retweet.csv')
json2csv_entities(self.infile, outfn, ['id'], 'retweeted_status',
['created_at', 'favorite_count', 'id', 'in_reply_to_status_id',
'in_reply_to_user_id', 'retweet_count', 'text', 'truncated',
'user.id'],
gzip_compress=False)
self.assertTrue(are_files_identical(outfn, ref_fn), msg=self.msg)