質問編集履歴
2
一部エラー内容が変更されたので編集しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,35 +14,35 @@
|
|
14
14
|
|
15
15
|
TypeError Traceback (most recent call last)
|
16
16
|
|
17
|
-
/var/folders/1b/4r83ph916kb86bjsvm74d7740000gn/T/ipykernel_
|
17
|
+
/var/folders/1b/4r83ph916kb86bjsvm74d7740000gn/T/ipykernel_967/1406860841.py in <module>
|
18
18
|
|
19
|
-
|
19
|
+
38
|
20
20
|
|
21
|
-
|
21
|
+
39 #『こころ』から作成されたモデル
|
22
22
|
|
23
|
-
---
|
23
|
+
---> 40 model = kokoro()
|
24
24
|
|
25
|
-
|
25
|
+
41
|
26
26
|
|
27
|
-
|
27
|
+
42 #「人間」という単語に最も近い10単語を表示する
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
/var/folders/1b/4r83ph916kb86bjsvm74d7740000gn/T/ipykernel_
|
31
|
+
/var/folders/1b/4r83ph916kb86bjsvm74d7740000gn/T/ipykernel_967/1406860841.py in kokoro()
|
32
32
|
|
33
|
-
|
33
|
+
30
|
34
34
|
|
35
|
-
|
35
|
+
31 #単語の分散表現のモデル作成
|
36
36
|
|
37
|
-
---> 2
|
37
|
+
---> 32 v.vectorize()
|
38
38
|
|
39
|
-
|
39
|
+
33
|
40
40
|
|
41
|
-
|
41
|
+
34 #できたモデルを返す
|
42
42
|
|
43
43
|
|
44
44
|
|
45
|
-
~/プログラミング/Mercurial用/pythonren/word2vecren/word2vecre
|
45
|
+
~/プログラミング/Mercurial用/pythonren/word2vecren/my_word2vec/my_word2vec/vectorizer.py in vectorize(self, other_file_dir, sg, size, min_count, window, hs, negative, iter)
|
46
46
|
|
47
47
|
51 else:
|
48
48
|
|
@@ -56,13 +56,13 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
~/プログラミング/Mercurial用/pythonren/word2vecren/word2vecre
|
59
|
+
~/プログラミング/Mercurial用/pythonren/word2vecren/my_word2vec/my_word2vec/vectorizer.py in _train(self, sentences, sg, size, min_count, window, hs, negative, iter)
|
60
60
|
|
61
61
|
62 word2vecの引数 : 詳細はgensimのドキュメント参照
|
62
62
|
|
63
63
|
63 """
|
64
64
|
|
65
|
-
---> 64 self.model = word2vec.Word2Vec(sentences, sg=sg, size=size, min_count=min_count, window=window, hs=hs, negative=negative, iter=iter)
|
65
|
+
---> 64 self.model = word2vec.Word2Vec(sentences, sg=sg, vector_size=size, min_count=min_count, window=window, hs=hs, negative=negative, iter=iter)
|
66
66
|
|
67
67
|
65
|
68
68
|
|
@@ -70,4 +70,4 @@
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
-
TypeError: __init__() got an unexpected keyword argument '
|
73
|
+
TypeError: __init__() got an unexpected keyword argument 'iter'
|
1
辞書を追加したら一部エラーが消えました
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,134 +10,64 @@
|
|
10
10
|
|
11
11
|
エラー内容
|
12
12
|
|
13
|
-
|
14
|
-
|
15
13
|
---------------------------------------------------------------------------
|
16
14
|
|
17
|
-
|
15
|
+
TypeError Traceback (most recent call last)
|
18
16
|
|
19
|
-
/
|
17
|
+
/var/folders/1b/4r83ph916kb86bjsvm74d7740000gn/T/ipykernel_1347/479110100.py in <module>
|
20
18
|
|
21
|
-
|
19
|
+
2
|
22
20
|
|
23
|
-
|
21
|
+
3 #『こころ』から作成されたモデル
|
24
22
|
|
25
|
-
|
23
|
+
----> 4 model = kokoro()
|
24
|
+
|
25
|
+
5
|
26
|
+
|
27
|
+
6 #「人間」という単語に最も近い10単語を表示する
|
26
28
|
|
27
29
|
|
28
30
|
|
31
|
+
/var/folders/1b/4r83ph916kb86bjsvm74d7740000gn/T/ipykernel_1347/2512386214.py in kokoro()
|
32
|
+
|
33
|
+
25
|
34
|
+
|
35
|
+
26 #単語の分散表現のモデル作成
|
36
|
+
|
37
|
+
---> 27 v.vectorize()
|
38
|
+
|
39
|
+
28
|
40
|
+
|
29
|
-
|
41
|
+
29 #できたモデルを返す
|
30
42
|
|
31
43
|
|
32
44
|
|
45
|
+
~/プログラミング/Mercurial用/pythonren/word2vecren/word2vecren2.py in vectorize(self, other_file_dir, sg, size, min_count, window, hs, negative, iter)
|
46
|
+
|
47
|
+
51 else:
|
48
|
+
|
33
|
-
|
49
|
+
52 sentences = word2vec.Text8Corpus(other_file_dir)
|
50
|
+
|
51
|
+
---> 53 self._train(sentences, sg, size, min_count, window, hs, negative, iter)
|
52
|
+
|
53
|
+
54
|
54
|
+
|
55
|
+
55 def _train(self, sentences, sg=1, size=300, min_count=10, window=5, hs=0, negative=15, iter=15):
|
34
56
|
|
35
57
|
|
36
58
|
|
37
|
-
|
59
|
+
~/プログラミング/Mercurial用/pythonren/word2vecren/word2vecren2.py in _train(self, sentences, sg, size, min_count, window, hs, negative, iter)
|
38
60
|
|
39
|
-
|
61
|
+
62 word2vecの引数 : 詳細はgensimのドキュメント参照
|
40
62
|
|
41
|
-
3
|
63
|
+
63 """
|
42
64
|
|
43
|
-
|
65
|
+
---> 64 self.model = word2vec.Word2Vec(sentences, sg=sg, size=size, min_count=min_count, window=window, hs=hs, negative=negative, iter=iter)
|
44
66
|
|
45
|
-
|
67
|
+
65
|
46
68
|
|
47
|
-
41
|
48
|
-
|
49
|
-
|
69
|
+
66 def save_model(self, model_dir):
|
50
70
|
|
51
71
|
|
52
72
|
|
53
|
-
/var/folders/1b/4r83ph916kb86bjsvm74d7740000gn/T/ipykernel_1907/3518633845.py in kokoro()
|
54
|
-
|
55
|
-
25 #__init__で文章が分かち書きされたファイル(out.txt)が同じディレクトリ内に作られる。
|
56
|
-
|
57
|
-
26 #dic_dir、user_dirは変更が必要
|
58
|
-
|
59
|
-
---> 27 v = Vectorizer(file_dir="kokoro.txt",\
|
60
|
-
|
61
|
-
28 dic_dir="/usr/local/lib/mecab/dic/mecab-ipadic-neologd",\
|
62
|
-
|
63
|
-
29 user_dir="/Users/ユーザ名/Desktop/word2vec/user.dic")
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
~/プログラミング/Mercurial用/pythonren/word2vecren/my_word2vec/my_word2vec/vectorizer.py in __init__(self, file_dir, dic_dir, user_dir, out_dir, hinshis)
|
68
|
-
|
69
|
-
30 model : モデル(Noneで初期化)
|
70
|
-
|
71
|
-
31 """
|
72
|
-
|
73
|
-
---> 32 Wakati.__init__(self, file_dir, dic_dir, user_dir, hinshis)
|
74
|
-
|
75
|
-
33 self.out_dir = out_dir
|
76
|
-
|
77
|
-
34 self.model = None
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
~/プログラミング/Mercurial用/pythonren/word2vecren/my_word2vec/my_word2vec/wakati.py in __init__(self, file_dir, dic_dir, user_dir, hinshis)
|
82
|
-
|
83
|
-
29 """
|
84
|
-
|
85
|
-
30 if dic_dir is not None and user_dir is not None:
|
86
|
-
|
87
|
-
---> 31 self.tagger = MeCab.Tagger("mecabrc -d {} -u {}".format(dic_dir, user_dir))
|
88
|
-
|
89
|
-
32 elif dic_dir is not None:
|
90
|
-
|
91
|
-
33 self.tagger = MeCab.Tagger("mecabrc -d {}".format(dic_dir))
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
/usr/local/lib/python3.9/site-packages/MeCab/__init__.py in __init__(self, rawargs)
|
96
|
-
|
97
|
-
133 super(Tagger, self).__init__(args)
|
98
|
-
|
99
|
-
134 except RuntimeError as ee:
|
100
|
-
|
101
|
-
--> 135 raise RuntimeError(error_info(rawargs)) from ee
|
102
|
-
|
103
|
-
136
|
104
|
-
|
105
|
-
137
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
RuntimeError:
|
110
|
-
|
111
|
-
----------------------------------------------------------
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
Failed initializing MeCab. Please see the README for possible solutions:
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
https://github.com/SamuraiT/mecab-python3#common-issues
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
73
|
+
TypeError: __init__() got an unexpected keyword argument 'size'
|
124
|
-
|
125
|
-
ERROR DETAILS below:
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
https://github.com/SamuraiT/mecab-python3/issues
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
issueを英語で書く必要はありません。
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
------------------- ERROR DETAILS ------------------------
|
138
|
-
|
139
|
-
arguments: mecabrc -d /usr/local/lib/mecab/dic/mecab-ipadic-neologd -u /Users/ユーザ名/Desktop/word2vec/user.dic
|
140
|
-
|
141
|
-
) [tokenizer_->open(param)] tokenizer.cpp(127) [d->open(dicfile[i])] dictionary.cpp(79) [dmmap_->open(file, mode)] no such file or directory: /Users/ユーザ名/Desktop/word2vec/user.dic
|
142
|
-
|
143
|
-
----------------------------------------------------------
|