質問編集履歴
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,4 +19,32 @@
|
|
19
19
|
node = node.next
|
20
20
|
return " ".join(word_list)
|
21
21
|
|
22
|
+
```
|
23
|
+
|
24
|
+
頂いた情報より手探りでコードを書き換えてみたのですがエラーが出てしまいました。
|
25
|
+
|
26
|
+
```python
|
27
|
+
|
28
|
+
def split_word(text,category):
|
29
|
+
tagger = MeCab.Tagger('-d /usr/local/lib/mecab/dic/mecab-ipadic-neologd')
|
30
|
+
sentense = ""
|
31
|
+
node = tagger.parseToNode(text)
|
32
|
+
word_list = []
|
33
|
+
|
34
|
+
while node:
|
35
|
+
#指定した品詞(category)のみ原型で抽出
|
36
|
+
if node.feature.split(",")[0] == category:
|
37
|
+
sentense += " "+node.feature.split(",")[6] #★変更点
|
38
|
+
else:pass
|
39
|
+
word_list.append(sentense)
|
40
|
+
node = node.next
|
41
|
+
return " ".join(word_list)
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
```エラーコード
|
46
|
+
|
47
|
+
File "pandas/_libs/lib.pyx", line 2859, in pandas._libs.lib.map_infer
|
48
|
+
TypeError: split_word() missing 1 required positional argument: 'category'
|
49
|
+
|
22
50
|
```
|