質問編集履歴

17

細かいところ

2023/01/17 00:29

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -9,7 +9,7 @@
9
9
  ### 実現したいこと
10
10
 
11
11
  pythonのライブラリ『tweepy』を使ってTwitterをスクレイピング
12
- した後、wordcloudを用いて使用頻度の高い単語などを表示したい
12
+ した後、wordcloudを用いて使用頻度の高い単語などを表示したい
13
13
 
14
14
 
15
15
  ### エラーメッセージ

16

修正

2023/01/12 07:08

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -32,7 +32,7 @@
32
32
  import matplotlib.pyplot as plt
33
33
  from wordcloud import WordCloud
34
34
  import seaborn as sns
35
- sns.set(font='Hiragino Sans')
35
+ sns.set(font='yuminl.ttf')
36
36
 
37
37
  CONSUMER_KEY = 'ffff'
38
38
  CONSUMER_SECRET = 'ffff'
@@ -43,7 +43,7 @@
43
43
  auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
44
44
  api = tweepy.API(auth)
45
45
 
46
- search_results = api.search_tweets(q="ゲーム", result_type="recent",tweet_mode='extended',count=5)
46
+ search_results = api.search_tweets(q="ゲーム", result_type="recent",tweet_mode='extended',count=50)
47
47
 
48
48
  tw_data = []
49
49
  for tweet in search_results:
@@ -111,7 +111,7 @@
111
111
  word_chain=' '.join(word_list)
112
112
 
113
113
  c=collections.Counter(word_list)
114
- font_path='C:/Windows/Fonts/Arial.ttf'
114
+ font_path='C:/Windows/Fonts/yuminl.ttf'
115
115
  words = ['https','t','co','自民','し','w','そう', 'ない', 'いる', 'する', 'まま', 'よう', 'てる', 'なる', 'こと', 'もう', 'いい', 'ある', 'ゆく', 'れる', 'ん', 'の']
116
116
  result = WordCloud(width=800, height=600, background_color='white',
117
117
  font_path=font_path,regexp=r"[\w']+",

15

更新

2023/01/12 06:10

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -15,7 +15,7 @@
15
15
  ### エラーメッセージ
16
16
 
17
17
  ```
18
- [('ゲーム', 3), ('RT', 2), ('@', 2), (':', 2), ('コス', 2), ('', 2), ('kinosunoki', 1), ('1つ', 1), ('長時間', 1), ('お客様', 1), ('朗報', 1), ('料金', 1), ('プラン', 1), ('1', 1), ('500', 1), ('', 1), ('遊び', 1), ('放題', 1), ('導入', 1), ('利用', 1)]
18
+ [('G', 2), ('123', 2), ('ゲーム', 2), ('https', 2), ('://', 2), ('t', 2), ('.', 2), ('co', 2), ('/', 2), ('', 2), ('イメージ', 2), ('@', 1), ('ba', 1), ('0797', 1), ('naj', 1), ('残念', 1), ('はずれ', 1), ('たる', 1), ('毎日', 1), ('挑戦', 1)]
19
19
 
20
20
  ```
21
21
 

14

更新

2023/01/12 04:08

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -15,10 +15,7 @@
15
15
  ### エラーメッセージ
16
16
 
17
17
  ```
18
- Traceback (most recent call last):
19
- File "D:\abcd\wordclouda.py", line 70, in <module>
20
- f.write(str(tw_text))
21
- UnicodeEncodeError: 'cp932' codec can't encode character '\u2728' in position 154: illegal multibyte sequence
18
+ [('ゲーム', 3), ('RT', 2), ('@', 2), (':', 2), ('コス', 2), ('パ', 2), ('kinosunoki', 1), ('1つ', 1), ('長時間', 1), ('お客様', 1), ('朗報', 1), ('料金', 1), ('プラン', 1), ('1', 1), ('500', 1), ('円', 1), ('遊び', 1), ('放題', 1), ('導入', 1), ('利用', 1)]
22
19
 
23
20
  ```
24
21
 
@@ -93,7 +90,7 @@
93
90
  df1=df.iat[2,1]
94
91
  df2=df.iat[3,1]
95
92
  tw_text=df1 + df2
96
- f=open('text.txt','w')
93
+ f=open('text.txt','w',encoding='UTF-8')
97
94
  f.write(str(tw_text))
98
95
  f.close
99
96
 

13

細かいとこ

2023/01/11 06:50

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -129,6 +129,6 @@
129
129
 
130
130
  ### 試したこと
131
131
 
132
- エラーが表示されるたびにエラー行部分を修正したり削除したりしていましたが最終的に行き詰まってしまいました
132
+ エラーが表示されるたびにエラー行部分を修正したり削除したりしていましたが最終的に行き詰まってしまいました
133
133
 
134
134
 

12

2023/01/04 15:44

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
  サイトに載っていたプログラムをそのままコピーした後
5
5
  必要なものをpipでインストールしましたがエラーが多く
6
6
  自分なりにプログラムを修正しても上手くいかず困っています。
7
- python完全初心者です。よろしくお願いします
7
+ python完全初心者です。よろしくお願いします
8
8
 
9
9
  ### 実現したいこと
10
10
 

11

ff

2022/12/28 10:37

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -15,7 +15,10 @@
15
15
  ### エラーメッセージ
16
16
 
17
17
  ```
18
- [('#', 2), ('@', 1), ('Aypic', 1), ('3', 1), ('かき', 1), ('Peing', 1), ('質問', 1), ('箱', 1), ('https', 1), ('://', 1), ('t', 1), ('.', 1), ('co', 1), ('/', 1), ('T', 1), ('2', 1), ('EeU', 1), ('8', 1), ('Anvd', 1)]
18
+ Traceback (most recent call last):
19
+ File "D:\abcd\wordclouda.py", line 70, in <module>
20
+ f.write(str(tw_text))
21
+ UnicodeEncodeError: 'cp932' codec can't encode character '\u2728' in position 154: illegal multibyte sequence
19
22
 
20
23
  ```
21
24
 
@@ -43,7 +46,7 @@
43
46
  auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
44
47
  api = tweepy.API(auth)
45
48
 
46
- search_results = api.search_tweets(q="かきくけこ", result_type="recent",tweet_mode='extended',count=5)
49
+ search_results = api.search_tweets(q="ゲーム", result_type="recent",tweet_mode='extended',count=5)
47
50
 
48
51
  tw_data = []
49
52
  for tweet in search_results:

10

d

2022/12/27 14:03

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -15,31 +15,7 @@
15
15
  ### エラーメッセージ
16
16
 
17
17
  ```
18
- Traceback (most recent call last):
19
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 242, in __init__
20
- font_bytes_path.decode("ascii")
21
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 22: ordinal not in range(128)
22
-
23
- During handling of the above exception, another exception occurred:
24
-
25
- Traceback (most recent call last):
26
- File "D:\abcd\wordclouda.py", line 94, in <module>
27
- stopwords=words).generate(word_chain)
28
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 639, in generate
29
- return self.generate_from_text(text)
30
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 621, in generate_from_text
31
- self.generate_from_frequencies(words)
32
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 453, in generate_from_frequencies
33
- self.generate_from_frequencies(dict(frequencies[:2]),
34
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 503, in generate_from_frequencies
35
- font = ImageFont.truetype(self.font_path, font_size)
36
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 976, in truetype
37
- return freetype(font)
38
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 973, in freetype
39
- return FreeTypeFont(font, size, index, encoding, layout_engine)
40
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 246, in __init__
41
- with open(font, "rb") as f:
42
- FileNotFoundError: [Errno 2] No such file or directory: '/System/Library/Fonts/ヒラギノ明朝 ProN.ttc'
18
+ [('#', 2), ('@', 1), ('Aypic', 1), ('3', 1), ('かき', 1), ('Peing', 1), ('質問', 1), ('箱', 1), ('https', 1), ('://', 1), ('t', 1), ('.', 1), ('co', 1), ('/', 1), ('T', 1), ('2', 1), ('EeU', 1), ('8', 1), ('Anvd', 1)]
43
19
 
44
20
  ```
45
21
 
@@ -67,7 +43,7 @@
67
43
  auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
68
44
  api = tweepy.API(auth)
69
45
 
70
- search_results = api.search_tweets(q="あいうえお", result_type="recent",tweet_mode='extended',count=5)
46
+ search_results = api.search_tweets(q="かきくけこ", result_type="recent",tweet_mode='extended',count=5)
71
47
 
72
48
  tw_data = []
73
49
  for tweet in search_results:
@@ -135,7 +111,7 @@
135
111
  word_chain=' '.join(word_list)
136
112
 
137
113
  c=collections.Counter(word_list)
138
- font_path='/System/Library/Fonts/ヒラギノ明朝 ProN.ttc'
114
+ font_path='C:/Windows/Fonts/Arial.ttf'
139
115
  words = ['https','t','co','自民','し','w','そう', 'ない', 'いる', 'する', 'まま', 'よう', 'てる', 'なる', 'こと', 'もう', 'いい', 'ある', 'ゆく', 'れる', 'ん', 'の']
140
116
  result = WordCloud(width=800, height=600, background_color='white',
141
117
  font_path=font_path,regexp=r"[\w']+",

9

kk

2022/12/26 14:20

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -23,7 +23,7 @@
23
23
  During handling of the above exception, another exception occurred:
24
24
 
25
25
  Traceback (most recent call last):
26
- File "D:\卒業制作\wordclouda.py", line 94, in <module>
26
+ File "D:\abcd\wordclouda.py", line 94, in <module>
27
27
  stopwords=words).generate(word_chain)
28
28
  File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 639, in generate
29
29
  return self.generate_from_text(text)

8

ff

2022/12/26 14:19

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -14,12 +14,32 @@
14
14
 
15
15
  ### エラーメッセージ
16
16
 
17
+ ```
17
- ```Traceback (most recent call last):
18
+ Traceback (most recent call last):
19
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 242, in __init__
20
+ font_bytes_path.decode("ascii")
21
+ UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 22: ordinal not in range(128)
22
+
23
+ During handling of the above exception, another exception occurred:
24
+
25
+ Traceback (most recent call last):
18
- File "D:\abcd\wordclouda.py", line 74, in <module>
26
+ File "D:\卒業制作\wordclouda.py", line 94, in <module>
27
+ stopwords=words).generate(word_chain)
28
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 639, in generate
19
- text=f.read()
29
+ return self.generate_from_text(text)
30
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 621, in generate_from_text
31
+ self.generate_from_frequencies(words)
32
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 453, in generate_from_frequencies
33
+ self.generate_from_frequencies(dict(frequencies[:2]),
34
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\wordcloud\wordcloud.py", line 503, in generate_from_frequencies
35
+ font = ImageFont.truetype(self.font_path, font_size)
20
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode
36
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 976, in truetype
37
+ return freetype(font)
38
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 973, in freetype
21
- (result, consumed) = self._buffer_decode(data, self.errors, final)
39
+ return FreeTypeFont(font, size, index, encoding, layout_engine)
40
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageFont.py", line 246, in __init__
41
+ with open(font, "rb") as f:
22
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 16: invalid start byte
42
+ FileNotFoundError: [Errno 2] No such file or directory: '/System/Library/Fonts/ヒラギノ明朝 ProN.ttc'
23
43
 
24
44
  ```
25
45
 
@@ -98,9 +118,10 @@
98
118
  f.write(str(tw_text))
99
119
  f.close
100
120
 
101
- f= open("text.txt", 'r', encoding='UTF-8')
121
+ #f= open("text.txt", 'r', encoding='UTF-8')
102
- text=f.read()
122
+ #text=f.read()
103
- f.close()
123
+ #f.close()
124
+ text=tw_text
104
125
  tagger =MeCab.Tagger()
105
126
  tagger.parse('')
106
127
  node = tagger.parseToNode(text)

7

jj

2022/12/26 14:05

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -14,11 +14,13 @@
14
14
 
15
15
  ### エラーメッセージ
16
16
 
17
- ```
18
- Traceback (most recent call last):
17
+ ```Traceback (most recent call last):
19
- File "D:\abcd\wordclouda.py", line 73, in <module>
18
+ File "D:\abcd\wordclouda.py", line 74, in <module>
19
+ text=f.read()
20
+ File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode
21
+ (result, consumed) = self._buffer_decode(data, self.errors, final)
20
- f= open("/text.txt", 'r', encoding='UTF-8')
22
+ UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 16: invalid start byte
21
- FileNotFoundError: [Errno 2] No such file or directory: '/text.txt'
23
+
22
24
  ```
23
25
 
24
26
  ### ソースコード(個人情報は文字列ffffに変更してます)
@@ -96,7 +98,7 @@
96
98
  f.write(str(tw_text))
97
99
  f.close
98
100
 
99
- f= open("/text.txt", 'r', encoding='UTF-8')
101
+ f= open("text.txt", 'r', encoding='UTF-8')
100
102
  text=f.read()
101
103
  f.close()
102
104
  tagger =MeCab.Tagger()

6

jj

2022/12/26 14:03

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -96,7 +96,7 @@
96
96
  f.write(str(tw_text))
97
97
  f.close
98
98
 
99
- f= open("/text.txt", 'r', encoding='UTF-8')
99
+ f= open("/text.txt", 'r', encoding='UTF-8')
100
100
  text=f.read()
101
101
  f.close()
102
102
  tagger =MeCab.Tagger()

5

jj

2022/12/26 13:54

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -89,8 +89,8 @@
89
89
  #tw_dataのリストをpandasのDataFrameに変換
90
90
  df = pd.DataFrame(tw_data,columns=labels)
91
91
 
92
- df1=df.iat[2,2]
92
+ df1=df.iat[2,1]
93
- df2=df.iat[3,2]
93
+ df2=df.iat[3,1]
94
94
  tw_text=df1 + df2
95
95
  f=open('text.txt','w')
96
96
  f.write(str(tw_text))

4

通知

2022/12/26 13:22

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
  サイトに載っていたプログラムをそのままコピーした後
5
5
  必要なものをpipでインストールしましたがエラーが多く
6
6
  自分なりにプログラムを修正しても上手くいかず困っています。
7
- python完全初心者です。よろしくお願いします
7
+ python完全初心者です。よろしくお願いします
8
8
 
9
9
  ### 実現したいこと
10
10
 

3

誤字

2022/12/26 13:22

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -127,6 +127,6 @@
127
127
 
128
128
  ### 試したこと
129
129
 
130
- エラーが表示されるたびにエラー行部分を修正したり削除したりしていましたが最終的に行き詰ってしまいました
130
+ エラーが表示されるたびにエラー行部分を修正したり削除したりしていましたが最終的に行き詰ってしまいました
131
131
 
132
132
 

2

更新

2022/12/26 13:19

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -16,9 +16,9 @@
16
16
 
17
17
  ```
18
18
  Traceback (most recent call last):
19
- File "D:\abcd\wordclouda.py", line 70, in <module>
19
+ File "D:\abcd\wordclouda.py", line 73, in <module>
20
- f.write(tw_text)
20
+ f= open("/text.txt", 'r', encoding='UTF-8')
21
- TypeError: write() argument must be str, not numpy.int64
21
+ FileNotFoundError: [Errno 2] No such file or directory: '/text.txt'
22
22
  ```
23
23
 
24
24
  ### ソースコード(個人情報は文字列ffffに変更してます)
@@ -93,7 +93,7 @@
93
93
  df2=df.iat[3,2]
94
94
  tw_text=df1 + df2
95
95
  f=open('text.txt','w')
96
- f.write(tw_text)
96
+ f.write(str(tw_text))
97
97
  f.close
98
98
 
99
99
  f= open("/text.txt", 'r', encoding='UTF-8')
@@ -127,7 +127,6 @@
127
127
 
128
128
  ### 試したこと
129
129
 
130
- エラーが表示されるたびにエラー行部分を修正したり削除したり
130
+ エラーが表示されるたびにエラー行部分を修正したり削除したりしていましたが最終的に行き詰ってしまいました
131
- していましたが最終的に行き詰ってしまいました
132
131
 
133
132
 

1

ミス

2022/12/26 12:04

投稿

sshagj705
sshagj705

スコア1

test CHANGED
File without changes
test CHANGED
@@ -15,28 +15,10 @@
15
15
  ### エラーメッセージ
16
16
 
17
17
  ```
18
- wordclouda.py
19
18
  Traceback (most recent call last):
20
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\construction.py", line 982, in _finalize_columns_and_data
21
- columns = _validate_or_indexify_columns(contents, columns)
22
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\construction.py", line 1030, in _validate_or_indexify_columns
23
- raise AssertionError(
24
- AssertionError: 16 columns passed, passed data had 14 columns
25
-
26
- The above exception was the direct cause of the following exception:
27
-
28
- Traceback (most recent call last):
29
- File "D:\abcd\wordclouda.py", line 66, in <module>
19
+ File "D:\abcd\wordclouda.py", line 70, in <module>
30
- df = pd.DataFrame(tw_data,columns=labels)
20
+ f.write(tw_text)
31
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 721, in __init__
32
- arrays, columns, index = nested_data_to_arrays(
33
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\construction.py", line 519, in nested_data_to_arrays
34
- arrays, columns = to_arrays(data, columns, dtype=dtype)
35
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\construction.py", line 883, in to_arrays
36
- content, columns = _finalize_columns_and_data(arr, columns, dtype)
37
- File "C:\Users\PCUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\construction.py", line 985, in _finalize_columns_and_data
38
- raise ValueError(err) from err
39
- ValueError: 16 columns passed, passed data had 14 columns
21
+ TypeError: write() argument must be str, not numpy.int64
40
22
  ```
41
23
 
42
24
  ### ソースコード(個人情報は文字列ffffに変更してます)
@@ -89,7 +71,6 @@
89
71
  #CSVファイルに出力するときの列の名前を定義
90
72
  labels=[
91
73
  'ツイートID',
92
- 'ツイート時刻',
93
74
  'ツイート本文',
94
75
  'いいね数',
95
76
  'リツイート数',
@@ -99,7 +80,6 @@
99
80
  '自己紹介文',
100
81
  'フォロー数',
101
82
  'フォロワー数',
102
- 'アカウント作成日時',
103
83
  '自分のフォロー状況',
104
84
  'アイコン画像URL',
105
85
  'ヘッダー画像URL',
@@ -148,7 +128,6 @@
148
128
  ### 試したこと
149
129
 
150
130
  エラーが表示されるたびにエラー行部分を修正したり削除したり
151
- していましたが、error line 721など存在しない行などの修正を
152
- 促されわからなくなってしまいました
131
+ していましたが最終的に行き詰ってしまいました
153
132
 
154
133