前提・実現したいこと
pythonでtweetをmecabで形態素解析して文章生成をしようとしているのですが、TypeError: in method 'Tagger_parse', argument 2 of type 'char const *'というerrorが出て困っております。
調べてみたところstr型からbyte型にすればよいのかと思ったのですが、どこを変えればよいかわかないため質問させていただきました。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "test03.py", line 102, in <module> MeCab_file() File "test03.py", line 58, in MeCab_file wordlist = mt.parse(data) TypeError: in method 'Tagger_parse', argument 2 of type 'char const *'
該当のソースコード
python3
1 timeline = json.loads(req.text) 2 for tweet in timeline: 3 f = open("tweet.txt" , "a") 4 f = open("tweet.txt" , "w") 5 lists = (tweet["text"]) 6 str_lists = "https://api.twitter.com/1.1/statuses/home_timeline.json" 7 if "http" in lists: 8 lists = lists.split("http", 1)[0] 9 lists = lists.split("@")[0] 10 lists = lists.split("RT")[0] 11 12 f.write(lists) 13 f.flush() 14 f.close() 15 def MeCab_file(): 16 f = open("tweet.txt","rb") 17 data = f.read() 18 f.close() 19 mt = MeCab.Tagger("-Owakati") 20 wordlist = mt.parse(data) 21 wordlist = wordlist.rstrip(" \n").split(" ") 22 23
試したこと
補足情報(FW/ツールのバージョンなど)
python3.7 windows10 mecab64bit