回答編集履歴
2
メソッド名の変更
test
CHANGED
@@ -62,7 +62,7 @@
|
|
62
62
|
|
63
63
|
|
64
64
|
|
65
|
-
def convert_texts(file_name)
|
65
|
+
def convert_text_to_words(file_name)
|
66
66
|
|
67
67
|
lem = Lemmatizer.new
|
68
68
|
|
@@ -100,7 +100,7 @@
|
|
100
100
|
|
101
101
|
puts file_names_so.first
|
102
102
|
|
103
|
-
array = convert_texts(file_names_so.first)
|
103
|
+
array = convert_text_to_words(file_names_so.first)
|
104
104
|
|
105
105
|
# puts array
|
106
106
|
|
@@ -118,7 +118,7 @@
|
|
118
118
|
|
119
119
|
else
|
120
120
|
|
121
|
-
array = convert_texts(file_names_nso.first)
|
121
|
+
array = convert_text_to_words(file_names_nso.first)
|
122
122
|
|
123
123
|
puts file_names_nso.first
|
124
124
|
|
1
省略したコードの記載
test
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
|
23
|
-
require 'lemmatizer'
|
23
|
+
require 'lemmatizer' # 動詞を現形にするライブラリ
|
24
24
|
|
25
25
|
require 'active_support/all'
|
26
26
|
|
@@ -74,11 +74,15 @@
|
|
74
74
|
|
75
75
|
text.downcase
|
76
76
|
|
77
|
+
.gsub(/\,|\./, '')
|
78
|
+
|
79
|
+
.gsub(/\([a-z\s]+\)|\[[a-z\s]+\]|\'[a-z]+|\-|\—|\n|[0-9]+\:[0-9]+|[^a-z\s0-9]/, ' ') # ()と[]内の文字を空白に置換
|
80
|
+
|
77
|
-
|
81
|
+
.gsub(/\s+/, ' ')
|
78
82
|
|
79
83
|
.split
|
80
84
|
|
81
|
-
words.map { |w| lem.lemma(w.to_s).singularize }.sort # word内の単語を現在形
|
85
|
+
words.map { |w| lem.lemma(w.to_s).singularize }.sort # word内の単語を現在形 かつ単数形に変換
|
82
86
|
|
83
87
|
end
|
84
88
|
|
@@ -104,7 +108,23 @@
|
|
104
108
|
|
105
109
|
|
106
110
|
|
107
|
-
# NSO スクリプトの読み込み・変換処理
|
111
|
+
# NSO スクリプトの読み込み・変換処理
|
112
|
+
|
113
|
+
file_names_nso = file_name_list(script_type: :nso_script)
|
114
|
+
|
115
|
+
if file_names_nso.count.zero?
|
116
|
+
|
117
|
+
puts 'Empty...'
|
118
|
+
|
119
|
+
else
|
120
|
+
|
121
|
+
array = convert_texts(file_names_nso.first)
|
122
|
+
|
123
|
+
puts file_names_nso.first
|
124
|
+
|
125
|
+
# puts array
|
126
|
+
|
127
|
+
end
|
108
128
|
|
109
129
|
```
|
110
130
|
|