質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -41,3 +41,59 @@
|
|
41
41
|
|
42
42
|
|
43
43
|
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
頂いた情報より手探りでコードを書き換えてみたのですがエラーが出てしまいました。
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
```python
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def split_word(text,category):
|
56
|
+
|
57
|
+
tagger = MeCab.Tagger('-d /usr/local/lib/mecab/dic/mecab-ipadic-neologd')
|
58
|
+
|
59
|
+
sentense = ""
|
60
|
+
|
61
|
+
node = tagger.parseToNode(text)
|
62
|
+
|
63
|
+
word_list = []
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
while node:
|
68
|
+
|
69
|
+
#指定した品詞(category)のみ原型で抽出
|
70
|
+
|
71
|
+
if node.feature.split(",")[0] == category:
|
72
|
+
|
73
|
+
sentense += " "+node.feature.split(",")[6] #★変更点
|
74
|
+
|
75
|
+
else:pass
|
76
|
+
|
77
|
+
word_list.append(sentense)
|
78
|
+
|
79
|
+
node = node.next
|
80
|
+
|
81
|
+
return " ".join(word_list)
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```エラーコード
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
File "pandas/_libs/lib.pyx", line 2859, in pandas._libs.lib.map_infer
|
94
|
+
|
95
|
+
TypeError: split_word() missing 1 required positional argument: 'category'
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```
|