質問編集履歴
2
書式の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,6 +5,10 @@
|
|
5
5
|
当初はTweepyを用いて収集を行っていたのですが、TwitterAPIを用いた方法では1週間以上の過去のツイートに遡って収集が行えないのでGetOldTweetsというパッケージを使用しツイートの収集を行うことにしました。
|
6
6
|
|
7
7
|
しかし、Tweepyを用いて作っているプログラムをGetOldTweetsを利用したプログラムに変えて実行したところ以下のエラーメッセージが発生しました。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
追記:回答いただいたものを実行した結果、再びエラーが生じてしまったので当該エラーに変更しました。また、該当ソースコードも変更いたしました。
|
8
12
|
|
9
13
|
|
10
14
|
|
@@ -53,6 +57,8 @@
|
|
53
57
|
import got3 as got
|
54
58
|
|
55
59
|
import json
|
60
|
+
|
61
|
+
import itertools
|
56
62
|
|
57
63
|
import networkx as nx
|
58
64
|
|
1
該当プログラムが違うものを貼ってしまっていたので正しいものにしたのと、回答いただいたものを実行したものに変更しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,23 +14,23 @@
|
|
14
14
|
|
15
15
|
```
|
16
16
|
|
17
|
-
|
17
|
+
AttributeError Traceback (most recent call last)
|
18
18
|
|
19
|
-
<ipython-input-22
|
19
|
+
<ipython-input-35-d2284eea22e6> in <module>()
|
20
20
|
|
21
21
|
15 for v in tweet:
|
22
22
|
|
23
|
-
16
|
23
|
+
16 print(v.text)
|
24
24
|
|
25
|
-
---> 17
|
25
|
+
---> 17 for tag0, tag1 in itertools.combinations(v.entities['hashtags'], 2):
|
26
26
|
|
27
|
-
18
|
27
|
+
18 tag0 = tag0['text']
|
28
28
|
|
29
|
-
19
|
29
|
+
19 tag1 = tag1['text']
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
|
33
|
+
AttributeError: 'Tweet' object has no attribute 'entities'
|
34
34
|
|
35
35
|
```
|
36
36
|
|
@@ -70,25 +70,23 @@
|
|
70
70
|
|
71
71
|
print(tweet)
|
72
72
|
|
73
|
-
|
73
|
+
for v in tweet:
|
74
74
|
|
75
|
-
|
75
|
+
print(v.text)
|
76
76
|
|
77
|
-
|
77
|
+
for tag0, tag1 in itertools.combinations(v.entities['hashtags'], 2):
|
78
78
|
|
79
|
-
|
79
|
+
tag0 = tag0['text']
|
80
80
|
|
81
|
-
|
81
|
+
tag1 = tag1['text']
|
82
82
|
|
83
|
-
|
83
|
+
if G.has_edge(tag0, tag1):
|
84
84
|
|
85
|
-
|
85
|
+
G[tag0][tag1]["weight"] += 1
|
86
86
|
|
87
|
-
|
87
|
+
else:
|
88
88
|
|
89
|
-
else:
|
90
|
-
|
91
|
-
|
89
|
+
G.add_edge(tag0, tag1, weight=1)
|
92
90
|
|
93
91
|
```
|
94
92
|
|