質問編集履歴

1

コードの修正

2022/12/13 11:40

投稿

Neosoft_8319
Neosoft_8319

スコア2

test CHANGED
File without changes
test CHANGED
@@ -11,19 +11,14 @@
11
11
 
12
12
  ```
13
13
  ---------------------------------------------------------------------------
14
+ ---------------------------------------------------------------------------
14
- NameError Traceback (most recent call last)
15
+ TypeError Traceback (most recent call last)
15
- ~\AppData\Local\Temp\ipykernel_6896\1755109192.py in <module>
16
+ ~\AppData\Local\Temp\ipykernel_6896\659627611.py in <module>
16
17
  1 import my_mecab as mm
17
- ----> 2 out = mm.tokens("分析目的に合わせて自分で作るのがベストだが、人の作ったもの(SlothLib)を使うのもあり。", stopwords_list= stopwords)
18
+ ----> 2 out = mm.tokens("分析目的に合わせて自分で作るのがベストだが、人の作ったもの(SlothLib)を使うのもあり。", stopwords_lists= stopwords)
18
19
  3 print(out)
19
20
 
20
- ~\my_mecab.py in tokens(text, pos, stopwords_list)
21
- 12 elem= node.feature.split(",")
22
- 13 term= elem[6] if elem[6] !='*' else node.surface
23
- ---> 14 if term not in stopwords_lists:
24
- 15 if len(pos)<1 or elem[0] in pos:
25
- 16 word_list.append(term)
26
- NameError: name 'stopwords_lists' is not defined
21
+ TypeError: tokens() got an unexpected keyword argument 'stopwords_lists'
27
22
  ```
28
23
  ```
29
24
  ```
@@ -37,7 +32,7 @@
37
32
  path=""
38
33
  tagger=MeCab.Tagger(path)
39
34
 
40
- def tokens(text,pos =["名詞","形容詞","動詞"], stopwords_list=[]):
35
+ def tokens(text,pos =["名詞","形容詞","動詞"], stopwords_lists=[]):
41
36
  text= "".join(text.split())
42
37
  node=tagger.parseToNode(text)
43
38
  word_list=[]
@@ -58,7 +53,7 @@
58
53
  こちらがノートブックで実施したコードです。
59
54
  ```
60
55
  import my_mecab as mm
61
- out = mm.tokens("分析目的に合わせて自分で作るのがベストだが、人の作ったもの(SlothLib)を使うのもあり。", stopwords_list= stopwords)
56
+ out = mm.tokens("分析目的に合わせて自分で作るのがベストだが、人の作ったもの(SlothLib)を使うのもあり。", stopwords_lists= stopwords)
62
57
  print(out)
63
58
  ```
64
59