質問編集履歴
1
コードの追加、環境
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,35 @@
|
|
27
27
|
|
28
28
|
|
29
29
|
tfとdfを求めるためのアルゴリズム、手順をご教授いただけないでしょうか(汗)
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
<追記>コードはこんな感じです。
|
36
|
+
|
37
|
+
nounsというリストが上で説明したような名刺を入れている2次元のリストになります。
|
38
|
+
|
39
|
+
また、jupyter notebookでコードを書いています。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
from collections import Counter
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
def flatten_2dim(array):
|
50
|
+
|
51
|
+
return [item for sublist in array for item in sublist]
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
counter = Counter(flatten_2dim(nouns))
|
56
|
+
|
57
|
+
for word, cnt in counter.most_common():
|
58
|
+
|
59
|
+
print(word, cnt)
|
60
|
+
|
61
|
+
```
|